summaryrefslogtreecommitdiff
path: root/lib/thread.c
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-07-06 12:55:03 -0400
committerMark Stapp <mjs@voltanet.io>2020-10-23 08:59:34 -0400
commitb3d6bc6ef0140a194b4bc2993a6aba72ab5d54c9 (patch)
treeb5ef6dcab41d9da516a6ff044056e0faca7b35da /lib/thread.c
parent90a65457d12d8d90bf47eab1a4bb5446b3810d96 (diff)
* : update signature of thread_cancel api
Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'lib/thread.c')
-rw-r--r--lib/thread.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/thread.c b/lib/thread.c
index db35a3f031..90c6c6f0a8 100644
--- a/lib/thread.c
+++ b/lib/thread.c
@@ -1163,19 +1163,26 @@ void thread_cancel_event(struct thread_master *master, void *arg)
*
* @param thread task to cancel
*/
-void thread_cancel(struct thread *thread)
+void thread_cancel(struct thread **thread)
{
- struct thread_master *master = thread->master;
+ struct thread_master *master;
+
+ if (thread == NULL || *thread == NULL)
+ return;
+
+ master = (*thread)->master;
assert(master->owner == pthread_self());
frr_with_mutex(&master->mtx) {
struct cancel_req *cr =
XCALLOC(MTYPE_TMP, sizeof(struct cancel_req));
- cr->thread = thread;
+ cr->thread = *thread;
listnode_add(master->cancel_req, cr);
do_thread_cancel(master);
}
+
+ *thread = NULL;
}
/**