summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/workqueue.c12
-rw-r--r--src/common/workqueue.h2
2 files changed, 8 insertions, 6 deletions
diff --git a/src/common/workqueue.c b/src/common/workqueue.c
index 9293e1f9f0..44cf98d0dc 100644
--- a/src/common/workqueue.c
+++ b/src/common/workqueue.c
@@ -119,27 +119,29 @@ workqueue_entry_free(workqueue_entry_t *ent)
* executed in the main thread; that will cause undefined behavior (probably,
* a crash).
*
- * If the work is cancelled, this function return 1. It is the caller's
- * responsibility to free any storage in the work function's arguments.
+ * If the work is cancelled, this function return the argument passed to the
+ * work function. It is the caller's responsibility to free this storage.
*
* This function will have no effect if the worker thread has already executed
- * or begun to execute the work item. In that case, it will return 0.
+ * or begun to execute the work item. In that case, it will return NULL.
*/
-int
+void *
workqueue_entry_cancel(workqueue_entry_t *ent)
{
int cancelled = 0;
+ void *result = NULL;
tor_mutex_acquire(&ent->on_thread->lock);
if (ent->pending) {
TOR_TAILQ_REMOVE(&ent->on_thread->work, ent, next_work);
cancelled = 1;
+ result = ent->arg;
}
tor_mutex_release(&ent->on_thread->lock);
if (cancelled) {
tor_free(ent);
}
- return cancelled;
+ return result;
}
/**
diff --git a/src/common/workqueue.h b/src/common/workqueue.h
index 5a6cd80fb0..ec1f7c9000 100644
--- a/src/common/workqueue.h
+++ b/src/common/workqueue.h
@@ -32,7 +32,7 @@ int threadpool_queue_for_all(threadpool_t *pool,
int (*fn)(void *, void *),
void (*reply_fn)(void *),
void *arg);
-int workqueue_entry_cancel(workqueue_entry_t *pending_work);
+void *workqueue_entry_cancel(workqueue_entry_t *pending_work);
threadpool_t *threadpool_new(int n_threads,
replyqueue_t *replyqueue,
void *(*new_thread_state_fn)(void*),