aboutsummaryrefslogtreecommitdiff
path: root/src/common/workqueue.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-09-28 00:33:10 -0400
committerNick Mathewson <nickm@torproject.org>2015-01-14 11:17:46 -0500
commite5f8c772f4c468a20da8b9176c2b276ac76bbe78 (patch)
tree22b763ad1eaf3903ce95b5b061cdac5bcac6047d /src/common/workqueue.c
parentebbc177005eaf9bd949daba657b2c703a7bd1769 (diff)
downloadtor-e5f8c772f4c468a20da8b9176c2b276ac76bbe78.tar.gz
tor-e5f8c772f4c468a20da8b9176c2b276ac76bbe78.zip
Test and fix workqueue_entry_cancel().
Diffstat (limited to 'src/common/workqueue.c')
-rw-r--r--src/common/workqueue.c12
1 files changed, 7 insertions, 5 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;
}
/**