return WQ_RPL_REPLY;
}
+static int
+workqueue_shutdown_error(void *state, void *work)
+{
+ (void)state;
+ (void)work;
+ return WQ_RPL_REPLY;
+}
+
static void *
new_state(void *arg)
{
static int rsa_sent = 0;
static int ecdh_sent = 0;
static int n_received = 0;
+static int no_shutdown = 0;
#ifdef TRACK_RESPONSES
bitarray_t *received;
++n_received;
}
+/* This should never get called. */
+static void
+handle_reply_shutdown(void *arg)
+{
+ (void)arg;
+ no_shutdown = 1;
+}
+
static workqueue_entry_t *
add_work(threadpool_t *tp)
{
shutting_down = 1;
threadpool_queue_update(tp, NULL,
workqueue_do_shutdown, NULL, NULL);
+ // Anything we add after starting the shutdown must not be executed.
+ threadpool_queue_work(tp, workqueue_shutdown_error, handle_reply_shutdown, NULL);
{
struct timeval limit = { 2, 0 };
tor_event_base_loopexit(tor_libevent_get_base(), &limit);
printf("%d+%d vs %d\n", n_received, n_successful_cancel, n_sent);
puts("FAIL");
return 1;
+ } else if (no_shutdown) {
+ puts("Accepted work after shutdown\n");
+ puts("FAIL");
} else {
puts("OK");
return 0;