diff options
-rw-r--r-- | lib/tevent/tevent.h | 22 | ||||
-rw-r--r-- | lib/tevent/tevent_queue.c | 13 |
2 files changed, 35 insertions, 0 deletions
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) { |