summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/timer.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2008-05-08 07:43:04 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2008-05-08 07:43:04 +0000
commit4f3dc0e49eac2418817b621b230b9de5bb1908b0 (patch)
tree21b86fef5aba5b0116a4c0880016e7e5ecf4a4ef /usr.sbin/bgpd/timer.c
parentf3e8e0f5664a933acae70de549cdd3ea36d52d8f (diff)
take advantage of the timewheel: instead of checking each an every
timer, just get the first off the queue and check wether it is due
Diffstat (limited to 'usr.sbin/bgpd/timer.c')
-rw-r--r--usr.sbin/bgpd/timer.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c
index b2dce26e63a..ad07f5da073 100644
--- a/usr.sbin/bgpd/timer.c
+++ b/usr.sbin/bgpd/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.6 2008/05/08 07:40:03 henning Exp $ */
+/* $OpenBSD: timer.c,v 1.7 2008/05/08 07:43:03 henning Exp $ */
/*
* Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org>
@@ -45,6 +45,18 @@ timer_due(struct peer *p, enum Timer timer)
return (0);
}
+struct peer_timer *
+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);
+}
+
time_t
timer_nextduein(struct peer *p)
{