tevent: add tevent_queue_entry_untrigger()
authorStefan Metzmacher <metze@samba.org>
Thu, 15 Feb 2018 13:47:25 +0000 (14:47 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 23 Feb 2018 03:09:18 +0000 (04:09 +0100)
Pair-Programmed-With: Volker Lendecke <vl@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
lib/tevent/tevent.h
lib/tevent/tevent_queue.c

index c17d4e11b0d32f0e43108b5afb2f360413c4dd85..7bb9c618b2b2248ed3543750f1a2ee0249761a98 100644 (file)
@@ -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.
  *
index 5516c6cb1e5e96c66b79a7fe71667ac43b02953f..9c3973b731e5afc9f94962af5ae28e8482ce92e9 100644 (file)
@@ -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) {