From 6ced0e7f10d850d51f21200f5d3243cc1b90c453 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 17 Jan 2017 22:46:07 +0100 Subject: [PATCH] lib: time: remove recent_relative_time() Replace with monotime() [which is not cached]. Signed-off-by: David Lamparter --- bgpd/bgp_packet.c | 13 ++----------- lib/thread.c | 7 ------- lib/thread.h | 2 -- ospf6d/ospf6_area.c | 2 +- ospf6d/ospf6_neighbor.c | 8 +++----- ospf6d/ospf6_spf.c | 7 +------ ospfd/ospf_flood.c | 4 ++-- ospfd/ospf_lsa.c | 2 +- ospfd/ospf_nsm.c | 4 ++-- 9 files changed, 12 insertions(+), 37 deletions(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 38470a3c7e..b4f5cc1e8e 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -2153,15 +2153,6 @@ bgp_marker_all_one (struct stream *s, int length) return 1; } -/* Recent thread time. - On same clock base as bgp_clock (MONOTONIC) - but can be time of last context switch to bgp_read thread. */ -static time_t -bgp_recent_clock (void) -{ - return recent_relative_time().tv_sec; -} - /* Starting point of packet process function. */ int bgp_read (struct thread *thread) @@ -2288,14 +2279,14 @@ bgp_read (struct thread *thread) bgp_open_receive (peer, size); /* XXX return value ignored! */ break; case BGP_MSG_UPDATE: - peer->readtime = bgp_recent_clock (); + peer->readtime = monotime (NULL); bgp_update_receive (peer, size); break; case BGP_MSG_NOTIFY: bgp_notify_receive (peer, size); break; case BGP_MSG_KEEPALIVE: - peer->readtime = bgp_recent_clock (); + peer->readtime = monotime (NULL); bgp_keepalive_receive (peer, size); break; case BGP_MSG_ROUTE_REFRESH_NEW: diff --git a/lib/thread.c b/lib/thread.c index 64eaae45b9..711dd3b730 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -179,13 +179,6 @@ quagga_monotime (void) return tv.tv_sec; } -/* Public export of recent_relative_time by value */ -struct timeval -recent_relative_time (void) -{ - return relative_time; -} - static unsigned int cpu_record_hash_key (struct cpu_thread_history *a) { diff --git a/lib/thread.h b/lib/thread.h index c22bb4828d..a28768e50b 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -262,8 +262,6 @@ extern unsigned long thread_consumed_time(RUSAGE_T *after, RUSAGE_T *before, be used instead of calling gettimeofday if a recent value is sufficient. This is guaranteed to be refreshed before a thread is called. */ extern struct timeval recent_time; -/* Similar to recent_time, but a monotonically increasing time value */ -extern struct timeval recent_relative_time (void); /* only for use in logging functions! */ extern struct thread *thread_current; diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index d9cf97a713..198526a0eb 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -388,7 +388,7 @@ ospf6_area_show (struct vty *vty, struct ospf6_area *oa) if (oa->ts_spf.tv_sec || oa->ts_spf.tv_usec) { - result = timeval_elapsed (recent_relative_time (), oa->ts_spf); + result = monotime_since(&oa->ts_spf, NULL); if (result/TIMER_SECOND_MICRO > 0) { vty_out (vty, "SPF last executed %ld.%lds ago%s", diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index e9bb2493ff..f8a0d7a317 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -633,7 +633,7 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) { char router_id[16]; char duration[16]; - struct timeval now, res; + struct timeval res; char nstate[16]; char deadtime[16]; long h, m, s; @@ -645,13 +645,11 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) } #endif /*HAVE_GETNAMEINFO*/ - quagga_gettime (QUAGGA_CLK_MONOTONIC, &now); - /* Dead time */ h = m = s = 0; if (on->inactivity_timer) { - s = on->inactivity_timer->u.sands.tv_sec - recent_relative_time().tv_sec; + s = monotime_until(&on->inactivity_timer->u.sands, NULL) / 1000000LL; h = s / 3600; s -= h * 3600; m = s / 60; @@ -673,7 +671,7 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) } /* Duration */ - timersub (&now, &on->last_changed, &res); + monotime_since(&on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); /* diff --git a/ospf6d/ospf6_spf.c b/ospf6d/ospf6_spf.c index 04519e7d46..9014446374 100644 --- a/ospf6d/ospf6_spf.c +++ b/ospf6d/ospf6_spf.c @@ -670,7 +670,6 @@ void ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason) { unsigned long delay, elapsed, ht; - struct timeval now, result; ospf6_set_spf_reason(ospf6, reason); @@ -694,11 +693,7 @@ ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason) return; } - /* XXX Monotic timers: we only care about relative time here. */ - now = recent_relative_time (); - timersub (&now, &ospf6->ts_spf, &result); - - elapsed = (result.tv_sec * 1000) + (result.tv_usec / 1000); + elapsed = monotime_since(&ospf6->ts_spf, NULL) / 1000LL; ht = ospf6->spf_holdtime * ospf6->spf_hold_multiplier; if (ht > ospf6->spf_max_holdtime) diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 32dd8e8a91..417a7aa8d2 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -970,7 +970,7 @@ ospf_lsa_flush_area (struct ospf_lsa *lsa, struct ospf_area *area) more time for the ACK to be received and avoid retransmissions */ lsa->data->ls_age = htons (OSPF_LSA_MAXAGE); - lsa->tv_recv = recent_relative_time (); + monotime(&lsa->tv_recv); lsa->tv_orig = lsa->tv_recv; ospf_flood_through_area (area, NULL, lsa); ospf_lsa_maxage (area->ospf, lsa); @@ -983,7 +983,7 @@ ospf_lsa_flush_as (struct ospf *ospf, struct ospf_lsa *lsa) more time for the ACK to be received and avoid retransmissions */ lsa->data->ls_age = htons (OSPF_LSA_MAXAGE); - lsa->tv_recv = recent_relative_time (); + monotime(&lsa->tv_recv); lsa->tv_orig = lsa->tv_recv; ospf_flood_through_as (ospf, NULL, lsa); ospf_lsa_maxage (ospf, lsa); diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index 94575d5944..d4811c5b21 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -165,7 +165,7 @@ ospf_lsa_new () new->flags = 0; new->lock = 1; new->retransmit_counter = 0; - new->tv_recv = recent_relative_time (); + monotime(&new->tv_recv); new->tv_orig = new->tv_recv; new->refresh_list = -1; diff --git a/ospfd/ospf_nsm.c b/ospfd/ospf_nsm.c index 17cc1f66c2..ccb82bf8fe 100644 --- a/ospfd/ospf_nsm.c +++ b/ospfd/ospf_nsm.c @@ -630,10 +630,10 @@ nsm_notice_state_change (struct ospf_neighbor *nbr, int next_state, int event) /* Advance in NSM */ if (next_state > nbr->state) - nbr->ts_last_progress = recent_relative_time (); + monotime(&nbr->ts_last_progress); else /* regression in NSM */ { - nbr->ts_last_regress = recent_relative_time (); + monotime(&nbr->ts_last_regress); nbr->last_regress_str = ospf_nsm_event_str [event]; } -- 2.39.5