summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-09-11 13:49:20 -0400
committerNick Mathewson <nickm@torproject.org>2017-09-11 13:49:20 -0400
commit52c40330c8ab0c43c5773349d033ff7e49f02f53 (patch)
treeadcacd38defa6edde26e21f4c1e5ead281404b63 /src/common
parent67a5d4cb60a9f27e981b83195cf47183a7e9abcc (diff)
parent72ea4a8f081318c60c460cef5d9daf55e399c434 (diff)
downloadtor-52c40330c8ab0c43c5773349d033ff7e49f02f53.tar.gz
tor-52c40330c8ab0c43c5773349d033ff7e49f02f53.zip
Merge branch 'maint-0.3.1'
Diffstat (limited to 'src/common')
-rw-r--r--src/common/timers.c26
-rw-r--r--src/common/timers.h4
2 files changed, 22 insertions, 8 deletions
diff --git a/src/common/timers.c b/src/common/timers.c
index 6f4a6c30f0..c43c49c083 100644
--- a/src/common/timers.c
+++ b/src/common/timers.c
@@ -29,6 +29,8 @@
#include "orconfig.h"
+#define TOR_TIMERS_PRIVATE
+
#include "compat.h"
#include "compat_libevent.h"
#include "timers.h"
@@ -148,6 +150,21 @@ libevent_timer_reschedule(void)
event_add(global_timer_event, &d);
}
+/** Run the callback of every timer that has expired, based on the current
+ * output of monotime_get(). */
+STATIC void
+timers_run_pending(void)
+{
+ monotime_t now;
+ monotime_get(&now);
+ timer_advance_to_cur_time(&now);
+
+ tor_timer_t *t;
+ while ((t = timeouts_get(global_timeouts))) {
+ t->callback.cb(t, t->callback.arg, &now);
+ }
+}
+
/**
* Invoked when the libevent timer has expired: see which tor_timer_t events
* have fired, activate their callbacks, and reschedule the libevent timer.
@@ -159,14 +176,7 @@ libevent_timer_callback(evutil_socket_t fd, short what, void *arg)
(void)what;
(void)arg;
- monotime_t now;
- monotime_get(&now);
- timer_advance_to_cur_time(&now);
-
- tor_timer_t *t;
- while ((t = timeouts_get(global_timeouts))) {
- t->callback.cb(t, t->callback.arg, &now);
- }
+ timers_run_pending();
libevent_timer_reschedule();
}
diff --git a/src/common/timers.h b/src/common/timers.h
index e816630e6d..d9602cd2ae 100644
--- a/src/common/timers.h
+++ b/src/common/timers.h
@@ -22,5 +22,9 @@ void timer_free(tor_timer_t *t);
void timers_initialize(void);
void timers_shutdown(void);
+#ifdef TOR_TIMERS_PRIVATE
+STATIC void timers_run_pending(void);
+#endif
+
#endif