From 157df4da26aeb46eedf1a0f3895cc5fbc751f1dc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 23 Mar 2018 10:32:15 +0100 Subject: [PATCH] tevent: add tevent_threaded_schedule_immediate_destructor that just aborts This will be active while the event is part of the ev->scheduled_immediates list. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- lib/tevent/tevent_threads.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/tevent/tevent_threads.c b/lib/tevent/tevent_threads.c index 3f91ab8bc2a..efdac9856dd 100644 --- a/lib/tevent/tevent_threads.c +++ b/lib/tevent/tevent_threads.c @@ -441,6 +441,14 @@ struct tevent_threaded_context *tevent_threaded_context_create( #endif } +static int tevent_threaded_schedule_immediate_destructor(struct tevent_immediate *im) +{ + if (im->event_ctx != NULL) { + abort(); + } + return 0; +} + void _tevent_threaded_schedule_immediate(struct tevent_threaded_context *tctx, struct tevent_immediate *im, tevent_immediate_handler_t handler, @@ -484,6 +492,14 @@ void _tevent_threaded_schedule_immediate(struct tevent_threaded_context *tctx, .schedule_location = location, }; + /* + * Make sure the event won't be destroyed while + * it's part of the ev->scheduled_immediates list. + * _tevent_schedule_immediate() will reset the destructor + * in tevent_common_threaded_activate_immediate(). + */ + talloc_set_destructor(im, tevent_threaded_schedule_immediate_destructor); + ret = pthread_mutex_lock(&ev->scheduled_mutex); if (ret != 0) { abort(); -- 2.34.1