tevent: allow tevent_queue_add() to take a NULL trigger function
authorStefan Metzmacher <metze@samba.org>
Thu, 28 Jul 2011 07:45:15 +0000 (09:45 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 9 Aug 2011 14:17:10 +0000 (16:17 +0200)
This way the caller can add a blocker to the queue.

metze

lib/tevent/tevent.h
lib/tevent/tevent_queue.c

index 3b170a4dc8e02d7c0807c7fdc16ec1a0507b4f12..c96ca354f55e0366bd8118db223b7243bea32c8b 100644 (file)
@@ -1395,7 +1395,9 @@ typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
  * @param[in]  req      The tevent request to add to the queue.
  *
  * @param[in]  trigger  The function triggered by the queue when the request
- *                      is called.
+ *                      is called. Since tevent 0.9.14 it's possible to
+ *                      pass NULL, in order to just add a "blocker" to the
+ *                      queue.
  *
  * @param[in]  private_data The private data passed to the trigger function.
  *
index 446804c9a51e6cab027d30d1f7d769cc0197188c..3fca7fb9487c4e4f31fd46c92ba1984094c93418 100644 (file)
@@ -163,6 +163,13 @@ bool tevent_queue_add(struct tevent_queue *queue,
        e->trigger = trigger;
        e->private_data = private_data;
 
+       /*
+        * if there is no trigger, it is just a blocker
+        */
+       if (trigger == NULL) {
+               e->triggered = true;
+       }
+
        DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
        queue->length++;
        talloc_set_destructor(e, tevent_queue_entry_destructor);