]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add accessor for inspecting timer callbacks.
authorNick Mathewson <nickm@torproject.org>
Fri, 2 Dec 2016 17:15:07 +0000 (12:15 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 2 Dec 2016 17:15:07 +0000 (12:15 -0500)
src/common/timers.c
src/common/timers.h

index 41b2008ac4c6568bfe84c0d21c5266be3733e589..e1ad47b15b742b371ce817cd695b87edd5a1b986 100644 (file)
@@ -254,6 +254,20 @@ timer_set_cb(tor_timer_t *t, timer_cb_fn_t cb, void *arg)
   t->callback.arg = arg;
 }
 
+/**
+ * Set *<b>cb_out</b> (if provided) to this timer's callback function,
+ * and *<b>arg_out</b> (if provided) to this timer's callback argument.
+ */
+void
+timer_get_cb(const tor_timer_t *t,
+             timer_cb_fn_t *cb_out, void **arg_out)
+{
+  if (cb_out)
+    *cb_out = t->callback.cb;
+  if (arg_out)
+    *arg_out = t->callback.arg;
+}
+
 /**
  * Schedule the timer t to fire at the current time plus a delay of
  * <b>delay</b> microseconds.  All times are relative to monotime_get().
index 5f918f8e159a61c3ed8524a741cbefa841427aa8..c5246a3335a6b1d46bc6e35a282342a4e80ee98d 100644 (file)
@@ -13,6 +13,8 @@ typedef void (*timer_cb_fn_t)(tor_timer_t *, void *,
                               const struct monotime_t *);
 tor_timer_t *timer_new(timer_cb_fn_t cb, void *arg);
 void timer_set_cb(tor_timer_t *t, timer_cb_fn_t cb, void *arg);
+void timer_get_cb(const tor_timer_t *t,
+                  timer_cb_fn_t *cb_out, void **arg_out);
 void timer_schedule(tor_timer_t *t, const struct timeval *delay);
 void timer_disable(tor_timer_t *t);
 void timer_free(tor_timer_t *t);