diff options
author | 2019-05-24 11:37:52 +0000 | |
---|---|---|
committer | 2019-05-24 11:37:52 +0000 | |
commit | 1df74267cc7fad2deb6f7f6a8abecb5e06b261b4 (patch) | |
tree | e4431a6e5cadf49858982568ebd22e849b0a3856 /usr.sbin/bgpd/timer.c | |
parent | Pass extent for prefetchable mmio. Since there is no distinction between (diff) | |
download | wireguard-openbsd-1df74267cc7fad2deb6f7f6a8abecb5e06b261b4.tar.xz wireguard-openbsd-1df74267cc7fad2deb6f7f6a8abecb5e06b261b4.zip |
Change timer_nextisdue() and timer_nextduein() to take the current time
as an argument. This way getmonotime() can be called once at the start
of looping over all peers instead of twice during the loop.
Makes a big difference with many peers.
OK florian@ sthen@
Diffstat (limited to 'usr.sbin/bgpd/timer.c')
-rw-r--r-- | usr.sbin/bgpd/timer.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c index b1bb5eec279..36278fb0000 100644 --- a/usr.sbin/bgpd/timer.c +++ b/usr.sbin/bgpd/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.17 2017/01/24 04:22:42 benno Exp $ */ +/* $OpenBSD: timer.c,v 1.18 2019/05/24 11:37:52 claudio Exp $ */ /* * Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org> @@ -49,23 +49,23 @@ timer_get(struct peer *p, enum Timer timer) } struct peer_timer * -timer_nextisdue(struct peer *p) +timer_nextisdue(struct peer *p, time_t now) { struct peer_timer *pt; pt = TAILQ_FIRST(&p->timers); - if (pt != NULL && pt->val > 0 && pt->val <= getmonotime()) + if (pt != NULL && pt->val > 0 && pt->val <= now) return (pt); return (NULL); } time_t -timer_nextduein(struct peer *p) +timer_nextduein(struct peer *p, time_t now) { struct peer_timer *pt; if ((pt = TAILQ_FIRST(&p->timers)) != NULL && pt->val > 0) - return (MAXIMUM(pt->val - getmonotime(), 0)); + return (MAXIMUM(pt->val - now, 0)); return (-1); } |