From 70d08b00ab31f84f4c7e11c535bbcbfcf39a585b Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 13 Jul 2021 23:35:31 +0200 Subject: switch handover penalty timers to CLOCK_MONOTONIC To be able to add a fake time to handover tests, the penalty timers need to use an osmo_* time source. There already is a fixme comment rightfully asking for a monotonic clock, so this change is overdue anyway. An upcoming patch will prove that this works: "handover tests: test passing of penalty timeout" I65e59cc7309778cf9d71612669ce84d101c8135e Related: SYS#5198 Change-Id: Ifb1ab3165db50511aed4f65aa445798367d7e19e --- src/osmo-bsc/penalty_timers.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/osmo-bsc/penalty_timers.c b/src/osmo-bsc/penalty_timers.c index 689006114..124a36255 100644 --- a/src/osmo-bsc/penalty_timers.c +++ b/src/osmo-bsc/penalty_timers.c @@ -30,10 +30,10 @@ static unsigned int time_now(void) { - time_t now; - time(&now); - /* FIXME: use monotonic clock */ - return (unsigned int)now; + struct timespec tp; + if (osmo_clock_gettime(CLOCK_MONOTONIC, &tp)) + return 0; + return (unsigned int)tp.tv_sec; } /* Add a penalty timer for a target cell ID. -- cgit v1.2.3