diff options
author | Stefan Metzmacher <metze@samba.org> | 2018-02-15 14:47:25 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2018-04-20 11:53:09 +0200 |
commit | c2a333337da85afc921ae2dd0d8bbeeb7f435b89 (patch) | |
tree | 242c5e0a833363284d2275f60bc040aa0d02410c /lib | |
parent | 55b8d619cf3efd4d02dc9460c3b62e7b8a9ada83 (diff) | |
download | samba-c2a333337da85afc921ae2dd0d8bbeeb7f435b89.tar.gz |
tevent: add tevent_queue_entry_untrigger()
Bug: https://bugzilla.samba.org/show_bug.cgi?id=13291
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit 5c6f31697a8edb03d36eece5c79581b952743b5b)
Diffstat (limited to 'lib')
-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) { |