summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bgpd/timer.c
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2007-12-23 18:56:17 +0000
committerhenning <henning@openbsd.org>2007-12-23 18:56:17 +0000
commitf540baacc6bffa33ac468bf4e2922310f3b76a8d (patch)
tree2907d5d4b3c04d5d3b31f59cc35d18b5cb7f5b21 /usr.sbin/bgpd/timer.c
parentremove some unused #defines; ok henning@ (diff)
downloadwireguard-openbsd-f540baacc6bffa33ac468bf4e2922310f3b76a8d.tar.xz
wireguard-openbsd-f540baacc6bffa33ac468bf4e2922310f3b76a8d.zip
provide timer_nextduein, which provides the number of seconds until the
next timer expires. use that in the session engine's mainloop, which simplifies it and removes the last bits of timer internals knowledge from anywhere outside timer.c.
Diffstat (limited to 'usr.sbin/bgpd/timer.c')
-rw-r--r--usr.sbin/bgpd/timer.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/timer.c b/usr.sbin/bgpd/timer.c
index d6b97bd0896..a924a5d4339 100644
--- a/usr.sbin/bgpd/timer.c
+++ b/usr.sbin/bgpd/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.3 2007/12/23 18:26:13 henning Exp $ */
+/* $OpenBSD: timer.c,v 1.4 2007/12/23 18:56:17 henning Exp $ */
/*
* Copyright (c) 2003-2007 Henning Brauer <henning@openbsd.org>
@@ -55,6 +55,20 @@ timer_due(struct peer *p, enum Timer timer)
return (0);
}
+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;
+
+ return (r);
+}
+
int
timer_running(struct peer *p, enum Timer timer, time_t *left)
{