From: Stefan Metzmacher Date: Fri, 23 Mar 2018 09:32:15 +0000 (+0100) Subject: tevent: add tevent_threaded_schedule_immediate_destructor that just aborts X-Git-Tag: tevent-0.9.37~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=157df4da26aeb46eedf1a0f3895cc5fbc751f1dc;p=thirdparty%2Fsamba.git 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 --- 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();