From 5c6f31697a8edb03d36eece5c79581b952743b5b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 15 Feb 2018 14:47:25 +0100 Subject: tevent: add tevent_queue_entry_untrigger() Pair-Programmed-With: Volker Lendecke Signed-off-by: Stefan Metzmacher Signed-off-by: Volker Lendecke --- 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 @@ -1643,6 +1643,28 @@ struct tevent_queue_entry *tevent_queue_add_optimize_empty( tevent_queue_trigger_fn_t trigger, 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. * 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) { -- cgit v1.2.1