summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bgpd/timer.c
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2008-05-08 07:59:56 +0000
committerhenning <henning@openbsd.org>2008-05-08 07:59:56 +0000
commiteb9ba443cf9a0e7194b943ec8fd0557c41668e92 (patch)
treec0a974c0ac52443cbc327279a1a07873c966ea72 /usr.sbin/bgpd/timer.c
parentwe can stopin timer_set if new timeout equals the oldone. (diff)
downloadwireguard-openbsd-eb9ba443cf9a0e7194b943ec8fd0557c41668e92.tar.xz
wireguard-openbsd-eb9ba443cf9a0e7194b943ec8fd0557c41668e92.zip
take advanatge of the timewheelin timer_nextduein - we just need to look
at the first one
Diffstat (limited to 'usr.sbin/bgpd/timer.c')
-rw-r--r--usr.sbin/bgpd/timer.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c
index 4100ce6922f..9ce2f894980 100644
--- a/usr.sbin/bgpd/timer.c
+++ b/usr.sbin/bgpd/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.8 2008/05/08 07:45:21 henning Exp $ */
+/* $OpenBSD: timer.c,v 1.9 2008/05/08 07:59:56 henning Exp $ */
/*
* Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org>
@@ -51,7 +51,6 @@ timer_nextisdue(struct peer *p)
struct peer_timer *pt;
pt = TAILQ_FIRST(&p->timers);
-
if (pt != NULL && pt->val > 0 && pt->val <= time(NULL))
return (pt);
return (NULL);
@@ -60,15 +59,11 @@ timer_nextisdue(struct peer *p)
time_t
timer_nextduein(struct peer *p)
{
- u_int i;
- time_t d, r = -1;
-
- for (i = 1; i < Timer_Max; i++)
- if (timer_running(p, i, &d))
- if (r == -1 || d < r)
- r = d;
+ struct peer_timer *pt;
- return (r);
+ if ((pt = TAILQ_FIRST(&p->timers)) != NULL && pt->val > 0)
+ return (pt->val);
+ return (-1);
}
int
@@ -94,7 +89,7 @@ timer_set(struct peer *p, enum Timer timer, u_int offset)
fatal("timer_set");
pt->type = timer;
} else {
- if (pt->val == time(NULL) + offset)
+ if (pt->val == time(NULL) + (time_t)offset)
return;
TAILQ_REMOVE(&p->timers, pt, entry);
}