aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_libevent.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-12-06 19:49:20 -0500
committerNick Mathewson <nickm@torproject.org>2011-12-06 19:49:20 -0500
commit135a5102a3e5422a1c9c8ad28f58888eea4a2545 (patch)
tree1c69b5c10629b058e2e49aad6faf6db7ea483a77 /src/common/compat_libevent.c
parent50fd99d7ef01f74fd794eb430cf28b5c84e48446 (diff)
downloadtor-135a5102a3e5422a1c9c8ad28f58888eea4a2545.tar
tor-135a5102a3e5422a1c9c8ad28f58888eea4a2545.tar.gz
Revert "Make pending libevent actions cancelable"
This reverts commit aba25a6939a5907d40dbcff7433a8c130ffd12ad.
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r--src/common/compat_libevent.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 67f465927..3a754bef7 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -558,17 +558,17 @@ tor_check_libevent_header_compatibility(void)
#endif
}
-struct tor_libevent_action_t {
+typedef struct runnable_t {
struct event *ev;
void (*cb)(void *arg);
void *arg;
-};
+} runnable_t;
/** Callback for tor_run_in_libevent_loop */
static void
run_runnable_cb(evutil_socket_t s, short what, void *arg)
{
- tor_libevent_action_t *r = arg;
+ runnable_t *r = arg;
void (*cb)(void *) = r->cb;
void *cb_arg = r->arg;
(void)what;
@@ -584,32 +584,22 @@ run_runnable_cb(evutil_socket_t s, short what, void *arg)
* deep inside a no-reentrant code and there's some function you want to call
* without worrying about whether it might cause reeentrant invocation.
*/
-tor_libevent_action_t *
+int
tor_run_in_libevent_loop(void (*cb)(void *arg), void *arg)
{
- tor_libevent_action_t *r = tor_malloc(sizeof(tor_libevent_action_t));
+ runnable_t *r = tor_malloc(sizeof(runnable_t));
r->cb = cb;
r->arg = arg;
r->ev = tor_event_new(tor_libevent_get_base(), -1, EV_TIMEOUT,
run_runnable_cb, r);
if (!r->ev) {
tor_free(r);
- return NULL;
+ return -1;
}
/* Make the event active immediately. */
event_active(r->ev, EV_TIMEOUT, 1);
- return r;
-}
-
-/**
- * Cancel <b>action</b> without running it.
- */
-void
-tor_cancel_libevent_action(tor_libevent_action_t *action)
-{
- tor_event_free(action->ev);
- tor_free(action);
+ return 0;
}
/*