diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-10-03 12:49:34 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-04-05 12:36:28 -0400 |
commit | 6a5f62f68f2c73dbbbbddb4fa3759586f4c2b0dc (patch) | |
tree | fbe0eb2903fd46449070f552c756488763cf1b9f /src/or/cpuworker.c | |
parent | b3586629c9ce41393898b381159ba331906f8fc3 (diff) | |
download | tor-6a5f62f68f2c73dbbbbddb4fa3759586f4c2b0dc.tar.gz tor-6a5f62f68f2c73dbbbbddb4fa3759586f4c2b0dc.zip |
Move responsibility for threadpool reply-handler events to workqueue
This change makes cpuworker and test_workqueue no longer need to
include event2/event.h. Now workqueue.c needs to include it, but
that is at least somewhat logical here.
Diffstat (limited to 'src/or/cpuworker.c')
-rw-r--r-- | src/or/cpuworker.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index 7da7dc5f8b..083691c4f6 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -30,8 +30,6 @@ #include "router.h" #include "workqueue.h" -#include <event2/event.h> - static void queue_pending_tasks(void); typedef struct worker_state_s { @@ -69,22 +67,12 @@ worker_state_free_void(void *arg) static replyqueue_t *replyqueue = NULL; static threadpool_t *threadpool = NULL; -static struct event *reply_event = NULL; static tor_weak_rng_t request_sample_rng = TOR_WEAK_RNG_INIT; static int total_pending_tasks = 0; static int max_pending_tasks = 128; -static void -replyqueue_process_cb(evutil_socket_t sock, short events, void *arg) -{ - replyqueue_t *rq = arg; - (void) sock; - (void) events; - replyqueue_process(rq); -} - /** Initialize the cpuworker subsystem. It is OK to call this more than once * during Tor's lifetime. */ @@ -94,14 +82,6 @@ cpu_init(void) if (!replyqueue) { replyqueue = replyqueue_new(0); } - if (!reply_event) { - reply_event = tor_event_new(tor_libevent_get_base(), - replyqueue_get_socket(replyqueue), - EV_READ|EV_PERSIST, - replyqueue_process_cb, - replyqueue); - event_add(reply_event, NULL); - } if (!threadpool) { /* In our threadpool implementation, half the threads are permissive and @@ -115,7 +95,12 @@ cpu_init(void) worker_state_new, worker_state_free_void, NULL); + + int r = threadpool_register_reply_event(threadpool, NULL); + + tor_assert(r == 0); } + /* Total voodoo. Can we make this more sensible? */ max_pending_tasks = get_num_cpus(get_options()) * 64; crypto_seed_weak_rng(&request_sample_rng); |