Replace with monotime() [which is not cached].
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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)
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:
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)
{
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;
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",
{
char router_id[16];
char duration[16];
- struct timeval now, res;
+ struct timeval res;
char nstate[16];
char deadtime[16];
long h, m, s;
}
#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;
}
/* Duration */
- timersub (&now, &on->last_changed, &res);
+ monotime_since(&on->last_changed, &res);
timerstring (&res, duration, sizeof (duration));
/*
ospf6_spf_schedule (struct ospf6 *ospf6, unsigned int reason)
{
unsigned long delay, elapsed, ht;
- struct timeval now, result;
ospf6_set_spf_reason(ospf6, 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)
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);
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);
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;
/* 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];
}