From c2a333337da85afc921ae2dd0d8bbeeb7f435b89 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Feb 2018 14:47:25 +0100 Subject: [PATCH] tevent: add tevent_queue_entry_untrigger() Bug: https://bugzilla.samba.org/show_bug.cgi?id=13291 Pair-Programmed-With: Volker Lendecke Signed-off-by: Stefan Metzmacher Signed-off-by: Volker Lendecke (cherry picked from commit 5c6f31697a8edb03d36eece5c79581b952743b5b) --- lib/tevent/tevent.h | 22 ++++++++++++++++++++++ lib/tevent/tevent_queue.c | 13 +++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h index c17d4e11b0d..7bb9c618b2b 100644 --- a/lib/tevent/tevent.h +++ b/lib/tevent/tevent.h @@ -1644,6 +1644,28 @@ struct tevent_queue_entry *tevent_queue_add_optimize_empty( void *private_data); /** + * @brief Untrigger an already triggered queue entry. + * + * If a trigger function detects that it needs to remain + * in the queue, it needs to call tevent_queue_stop() + * followed by tevent_queue_entry_untrigger(). + * + * @note In order to call tevent_queue_entry_untrigger() + * the queue must be already stopped and the given queue_entry + * must be the first one in the queue! Otherwise it calls abort(). + * + * @note You can't use this together with tevent_queue_add_optimize_empty() + * because the trigger function don't have access to the quene entry + * in the case of an empty queue. + * + * @param[in] queue_entry The queue entry to rearm. + * + * @see tevent_queue_add_entry() + * @see tevent_queue_stop() + */ +void tevent_queue_entry_untrigger(struct tevent_queue_entry *entry); + +/** * @brief Start a tevent queue. * * The queue is started by default. diff --git a/lib/tevent/tevent_queue.c b/lib/tevent/tevent_queue.c index 5516c6cb1e5..9c3973b731e 100644 --- a/lib/tevent/tevent_queue.c +++ b/lib/tevent/tevent_queue.c @@ -266,6 +266,19 @@ struct tevent_queue_entry *tevent_queue_add_optimize_empty( trigger, private_data, true); } +void tevent_queue_entry_untrigger(struct tevent_queue_entry *entry) +{ + if (entry->queue->running) { + abort(); + } + + if (entry->queue->list != entry) { + abort(); + } + + entry->triggered = false; +} + void tevent_queue_start(struct tevent_queue *queue) { if (queue->running) { -- 2.11.4.GIT