[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Tue Aug 9 15:03:02 MDT 2011


The branch, master has been updated
       via  fd33829 tevent: change the version to 0.9.14 after the tevent_queue changes
       via  c6363bb tevent: fix some comments in tevent.h
       via  1533f17 tevent: add tevent_queue_add_entry() and tevent_queue_add_optimize_empty()
       via  6b7d58c tevent: splitout tevent_queue_add_internal() from tevent_queue_add()
       via  aba9d48 tevent: allow tevent_queue_add() to take a NULL trigger function
       via  3c38ec7 tevent: add tevent_queue_running() function
      from  1e76662 s3:vfs_prealloc: fix build on SLES8

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fd3382906a86aa7077aac535fee39cc5b441d682
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 9 16:12:40 2011 +0200

    tevent: change the version to 0.9.14 after the tevent_queue changes
    
    metze
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Tue Aug  9 23:02:17 CEST 2011 on sn-devel-104

commit c6363bb352daab5b5e4523df14ea8f20b630be75
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 9 16:05:36 2011 +0200

    tevent: fix some comments in tevent.h
    
    metze

commit 1533f1722de96f814c5e9de9aebc2892eb4bf882
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 28 10:45:22 2011 +0200

    tevent: add tevent_queue_add_entry() and tevent_queue_add_optimize_empty()
    
    This adds more flexible handling for the add operation:
    
    - It allows the caller to remove a tevent_req from the queue
      by calling talloc_free() on the returned tevent_queue_entry.
    - It allows the caller to optimize for the empty queue case,
      where it the caller wants to avoid the delay caused by
      the immediate event.
    
    metze

commit 6b7d58cb4ee3ed7796a8dc67c214a1b8439fbaeb
Author: Stefan Metzmacher <metze at samba.org>
Date:   Tue Aug 9 15:33:37 2011 +0200

    tevent: splitout tevent_queue_add_internal() from tevent_queue_add()
    
    metze

commit aba9d48f55b7e69af0967d0f435843c833357ec7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 28 09:45:15 2011 +0200

    tevent: allow tevent_queue_add() to take a NULL trigger function
    
    This way the caller can add a blocker to the queue.
    
    metze

commit 3c38ec72e74dd60b81964ebf661f5d5af8724968
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Jul 28 09:46:34 2011 +0200

    tevent: add tevent_queue_running() function
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 .../ABI/{tevent-0.9.13.sigs => tevent-0.9.14.sigs} |    3 +
 lib/tevent/tevent.h                                |   95 ++++++++++++++++++-
 lib/tevent/tevent_queue.c                          |   99 ++++++++++++++++++--
 lib/tevent/wscript                                 |    2 +-
 4 files changed, 187 insertions(+), 12 deletions(-)
 copy lib/tevent/ABI/{tevent-0.9.13.sigs => tevent-0.9.14.sigs} (93%)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/ABI/tevent-0.9.13.sigs b/lib/tevent/ABI/tevent-0.9.14.sigs
similarity index 93%
copy from lib/tevent/ABI/tevent-0.9.13.sigs
copy to lib/tevent/ABI/tevent-0.9.14.sigs
index 888ca0e..13c461c 100644
--- a/lib/tevent/ABI/tevent-0.9.13.sigs
+++ b/lib/tevent/ABI/tevent-0.9.14.sigs
@@ -41,7 +41,10 @@ tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
 tevent_loop_allow_nesting: void (struct tevent_context *)
 tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
 tevent_queue_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_entry: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_add_optimize_empty: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
 tevent_queue_length: size_t (struct tevent_queue *)
+tevent_queue_running: bool (struct tevent_queue *)
 tevent_queue_start: void (struct tevent_queue *)
 tevent_queue_stop: void (struct tevent_queue *)
 tevent_re_initialise: int (struct tevent_context *)
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 7ad566c..6e3ed76 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -1347,6 +1347,7 @@ struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
  */
 
 struct tevent_queue;
+struct tevent_queue_entry;
 
 #ifdef DOXYGEN
 /**
@@ -1358,8 +1359,8 @@ struct tevent_queue;
  *
  * @return              An allocated tevent queue on success, NULL on error.
  *
- * @see tevent_start()
- * @see tevent_stop()
+ * @see tevent_queue_start()
+ * @see tevent_queue_stop()
  */
 struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx,
 					 const char *name);
@@ -1381,6 +1382,8 @@ struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
  *                          tevent_queue_add().
  *
  * @see tevent_queue_add()
+ * @see tevent_queue_add_entry()
+ * @see tevent_queue_add_optimize_empty()
  */
 typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
 					  void *private_data);
@@ -1395,7 +1398,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.
  *
@@ -1409,6 +1414,79 @@ bool tevent_queue_add(struct tevent_queue *queue,
 		      void *private_data);
 
 /**
+ * @brief Add a tevent request to the queue.
+ *
+ * The request can be removed from the queue by calling talloc_free()
+ * (or a similar function) on the returned queue entry. This
+ * is the only difference to tevent_queue_add().
+ *
+ * @param[in]  queue    The queue to add the request.
+ *
+ * @param[in]  ev       The event handle to use for the request.
+ *
+ * @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. 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.
+ *
+ * @return              a pointer to the tevent_queue_entry if the request
+ *                      has been successfully added, NULL otherwise.
+ *
+ * @see tevent_queue_add()
+ * @see tevent_queue_add_optimize_empty()
+ */
+struct tevent_queue_entry *tevent_queue_add_entry(
+					struct tevent_queue *queue,
+					struct tevent_context *ev,
+					struct tevent_req *req,
+					tevent_queue_trigger_fn_t trigger,
+					void *private_data);
+
+/**
+ * @brief Add a tevent request to the queue using a possible optimization.
+ *
+ * This tries to optimize for the empty queue case and may calls
+ * the trigger function directly. This is the only difference compared
+ * to tevent_queue_add_entry().
+ *
+ * The caller needs to be prepared that the trigger function has
+ * already called tevent_req_notify_callback(), tevent_req_error(),
+ * tevent_req_done() or a similar function.
+ *
+ * The request can be removed from the queue by calling talloc_free()
+ * (or a similar function) on the returned queue entry.
+ *
+ * @param[in]  queue    The queue to add the request.
+ *
+ * @param[in]  ev       The event handle to use for the request.
+ *
+ * @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. 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.
+ *
+ * @return              a pointer to the tevent_queue_entry if the request
+ *                      has been successfully added, NULL otherwise.
+ *
+ * @see tevent_queue_add()
+ * @see tevent_queue_add_entry()
+ */
+struct tevent_queue_entry *tevent_queue_add_optimize_empty(
+					struct tevent_queue *queue,
+					struct tevent_context *ev,
+					struct tevent_req *req,
+					tevent_queue_trigger_fn_t trigger,
+					void *private_data);
+
+/**
  * @brief Start a tevent queue.
  *
  * The queue is started by default.
@@ -1435,6 +1513,17 @@ void tevent_queue_stop(struct tevent_queue *queue);
  */
 size_t tevent_queue_length(struct tevent_queue *queue);
 
+/**
+ * @brief Is the tevent queue running.
+ *
+ * The queue is started by default.
+ *
+ * @param[in]  queue    The queue.
+ *
+ * @return              Wether the queue is running or not..
+ */
+bool tevent_queue_running(struct tevent_queue *queue);
+
 typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
 				   void *private_data,
 				   uint32_t level,
diff --git a/lib/tevent/tevent_queue.c b/lib/tevent/tevent_queue.c
index 3715c35..4750675 100644
--- a/lib/tevent/tevent_queue.c
+++ b/lib/tevent/tevent_queue.c
@@ -144,17 +144,19 @@ static void tevent_queue_immediate_trigger(struct tevent_context *ev,
 	q->list->trigger(q->list->req, q->list->private_data);
 }
 
-bool tevent_queue_add(struct tevent_queue *queue,
-		      struct tevent_context *ev,
-		      struct tevent_req *req,
-		      tevent_queue_trigger_fn_t trigger,
-		      void *private_data)
+static struct tevent_queue_entry *tevent_queue_add_internal(
+					struct tevent_queue *queue,
+					struct tevent_context *ev,
+					struct tevent_req *req,
+					tevent_queue_trigger_fn_t trigger,
+					void *private_data,
+					bool allow_direct)
 {
 	struct tevent_queue_entry *e;
 
 	e = talloc_zero(req, struct tevent_queue_entry);
 	if (e == NULL) {
-		return false;
+		return NULL;
 	}
 
 	e->queue = queue;
@@ -163,16 +165,53 @@ 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;
+	}
+
+	if (queue->length > 0) {
+		/*
+		 * if there are already entries in the
+		 * queue do not optimize.
+		 */
+		allow_direct = false;
+	}
+
+	if (req->async.fn != NULL) {
+		/*
+		 * If the callers wants to optimize for the
+		 * empty queue case, call the trigger only
+		 * if there is no callback defined for the
+		 * request yet.
+		 */
+		allow_direct = false;
+	}
+
 	DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
 	queue->length++;
 	talloc_set_destructor(e, tevent_queue_entry_destructor);
 
 	if (!queue->running) {
-		return true;
+		return e;
 	}
 
 	if (queue->list->triggered) {
-		return true;
+		return e;
+	}
+
+	/*
+	 * If allowed we directly call the trigger
+	 * avoiding possible delays caused by
+	 * an immediate event.
+	 */
+	if (allow_direct) {
+		queue->list->triggered = true;
+		queue->list->trigger(queue->list->req,
+				     queue->list->private_data);
+		return e;
 	}
 
 	tevent_schedule_immediate(queue->immediate,
@@ -180,9 +219,48 @@ bool tevent_queue_add(struct tevent_queue *queue,
 				  tevent_queue_immediate_trigger,
 				  queue);
 
+	return e;
+}
+
+bool tevent_queue_add(struct tevent_queue *queue,
+		      struct tevent_context *ev,
+		      struct tevent_req *req,
+		      tevent_queue_trigger_fn_t trigger,
+		      void *private_data)
+{
+	struct tevent_queue_entry *e;
+
+	e = tevent_queue_add_internal(queue, ev, req,
+				      trigger, private_data, false);
+	if (e == NULL) {
+		return false;
+	}
+
 	return true;
 }
 
+struct tevent_queue_entry *tevent_queue_add_entry(
+					struct tevent_queue *queue,
+					struct tevent_context *ev,
+					struct tevent_req *req,
+					tevent_queue_trigger_fn_t trigger,
+					void *private_data)
+{
+	return tevent_queue_add_internal(queue, ev, req,
+					 trigger, private_data, false);
+}
+
+struct tevent_queue_entry *tevent_queue_add_optimize_empty(
+					struct tevent_queue *queue,
+					struct tevent_context *ev,
+					struct tevent_req *req,
+					tevent_queue_trigger_fn_t trigger,
+					void *private_data)
+{
+	return tevent_queue_add_internal(queue, ev, req,
+					 trigger, private_data, true);
+}
+
 void tevent_queue_start(struct tevent_queue *queue)
 {
 	if (queue->running) {
@@ -215,3 +293,8 @@ size_t tevent_queue_length(struct tevent_queue *queue)
 {
 	return queue->length;
 }
+
+bool tevent_queue_running(struct tevent_queue *queue)
+{
+	return queue->running;
+}
diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index a655909..68430ea 100644
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 
 APPNAME = 'tevent'
-VERSION = '0.9.13'
+VERSION = '0.9.14'
 
 blddir = 'bin'
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list