diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-03-23 10:25:27 +0100 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2018-07-11 23:04:19 +0200 |
commit | 0b91f6f0e4eeff7bbff24b33dd2087e2903e969b (patch) | |
tree | 4ed0be36f425cae4065e03bcb93d2b9badf65cf7 | |
parent | 788187c0309bf3bfcc7e056a3d78c2f4c2df7588 (diff) | |
download | samba-0b91f6f0e4eeff7bbff24b33dd2087e2903e969b.tar.gz |
tevent: use _tevent_schedule_immediate() to move events from a thread to the main_ev
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r-- | lib/tevent/tevent_immediate.c | 8 | ||||
-rw-r--r-- | lib/tevent/tevent_threads.c | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/tevent/tevent_immediate.c b/lib/tevent/tevent_immediate.c index 7b4c3e843de..c640a565b08 100644 --- a/lib/tevent/tevent_immediate.c +++ b/lib/tevent/tevent_immediate.c @@ -36,9 +36,11 @@ static void tevent_common_immediate_cancel(struct tevent_immediate *im) return; } - tevent_debug(im->event_ctx, TEVENT_DEBUG_TRACE, - "Cancel immediate event %p \"%s\"\n", - im, im->handler_name); + if (im->handler_name != NULL) { + tevent_debug(im->event_ctx, TEVENT_DEBUG_TRACE, + "Cancel immediate event %p \"%s\"\n", + im, im->handler_name); + } /* let the backend free im->additional_data */ if (im->cancel_fn) { diff --git a/lib/tevent/tevent_threads.c b/lib/tevent/tevent_threads.c index 728f8416d45..3f91ab8bc2a 100644 --- a/lib/tevent/tevent_threads.c +++ b/lib/tevent/tevent_threads.c @@ -532,8 +532,20 @@ void tevent_common_threaded_activate_immediate(struct tevent_context *ev) while (ev->scheduled_immediates != NULL) { struct tevent_immediate *im = ev->scheduled_immediates; + struct tevent_immediate copy = *im; + DLIST_REMOVE(ev->scheduled_immediates, im); - DLIST_ADD_END(ev->immediate_events, im); + + tevent_debug(ev, TEVENT_DEBUG_TRACE, + "Schedule immediate event \"%s\": %p from thread into main\n", + im->handler_name, im); + im->handler_name = NULL; + _tevent_schedule_immediate(im, + ev, + copy.handler, + copy.private_data, + copy.handler_name, + copy.schedule_location); } ret = pthread_mutex_unlock(&ev->scheduled_mutex); |