[SCM] Samba Shared Repository - branch master updated
Stefan Metzmacher
metze at samba.org
Sat Jul 9 04:17:02 MDT 2011
The branch, master has been updated
via 4768fc6 tevent: change version to 0.9.13 after adding tevent_req_defer_callback()
via e5827a4 tevent: add tevent_req_defer_callback()
via 2a1ebea tevent: fix comments for tevent_req_post()
from fe39925 Move smbd_smb2_request_check_tcon() smbd_smb2_request_check_session() next to their only user and make them static. Add comments.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 4768fc670401d86bd07ab366c5b0e81eb1998465
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 16:04:32 2011 +0200
tevent: change version to 0.9.13 after adding tevent_req_defer_callback()
metze
Autobuild-User: Stefan Metzmacher <metze at samba.org>
Autobuild-Date: Sat Jul 9 12:16:44 CEST 2011 on sn-devel-104
commit e5827a4007c553ddf7b0078538b17122c83b0087
Author: Stefan Metzmacher <metze at samba.org>
Date: Fri Jul 8 15:54:51 2011 +0200
tevent: add tevent_req_defer_callback()
metze
commit 2a1ebeae1976f4ecb8060deb829a62fe12b1fa39
Author: Stefan Metzmacher <metze at samba.org>
Date: Sat Jul 9 11:01:10 2011 +0200
tevent: fix comments for tevent_req_post()
metze
-----------------------------------------------------------------------
Summary of changes:
.../ABI/{tevent-0.9.12.sigs => tevent-0.9.13.sigs} | 1 +
lib/tevent/tevent.h | 46 +++++++++++++++++++-
lib/tevent/tevent_internal.h | 6 +++
lib/tevent/tevent_req.c | 12 +++++
lib/tevent/wscript | 2 +-
5 files changed, 64 insertions(+), 3 deletions(-)
copy lib/tevent/ABI/{tevent-0.9.12.sigs => tevent-0.9.13.sigs} (98%)
Changeset truncated at 500 lines:
diff --git a/lib/tevent/ABI/tevent-0.9.12.sigs b/lib/tevent/ABI/tevent-0.9.13.sigs
similarity index 98%
copy from lib/tevent/ABI/tevent-0.9.12.sigs
copy to lib/tevent/ABI/tevent-0.9.13.sigs
index df9b08d..888ca0e 100644
--- a/lib/tevent/ABI/tevent-0.9.12.sigs
+++ b/lib/tevent/ABI/tevent-0.9.13.sigs
@@ -47,6 +47,7 @@ tevent_queue_stop: void (struct tevent_queue *)
tevent_re_initialise: int (struct tevent_context *)
tevent_register_backend: bool (const char *, const struct tevent_ops *)
tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
+tevent_req_defer_callback: void (struct tevent_req *, struct tevent_context *)
tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *)
tevent_req_is_in_progress: bool (struct tevent_req *)
tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 8204a28..7ad566c 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -1016,7 +1016,7 @@ void _tevent_req_oom(struct tevent_req *req,
* the request without waiting for an external event, or it can not even start
* the engine. To present the illusion of a callback to the user of the API,
* the implementation can call this helper function which triggers an
- * immediate timed event. This way the caller can use the same calling
+ * immediate event. This way the caller can use the same calling
* conventions, independent of whether the request was actually deferred.
*
* @code
@@ -1040,7 +1040,7 @@ void _tevent_req_oom(struct tevent_req *req,
*
* @param[in] req The finished request.
*
- * @param[in] ev The tevent_context for the timed event.
+ * @param[in] ev The tevent_context for the immediate event.
*
* @return The given request will be returned.
*/
@@ -1048,6 +1048,48 @@ struct tevent_req *tevent_req_post(struct tevent_req *req,
struct tevent_context *ev);
/**
+ * @brief Finish multiple requests within one function
+ *
+ * Normally tevent_req_notify_callback() and all wrappers
+ * (e.g. tevent_req_done() and tevent_req_error())
+ * need to be the last thing an event handler should call.
+ * This is because the callback is likely to destroy the
+ * context of the current function.
+ *
+ * If a function wants to notify more than one caller,
+ * it is dangerous if it just triggers multiple callbacks
+ * in a row. With tevent_req_defer_callback() it is possible
+ * to set an event context that will be used to defer the callback
+ * via an immediate event (similar to tevent_req_post()).
+ *
+ * @code
+ * struct complete_state {
+ * struct tevent_context *ev;
+ *
+ * struct tevent_req **reqs;
+ * };
+ *
+ * void complete(struct complete_state *state)
+ * {
+ * size_t i, c = talloc_array_length(state->reqs);
+ *
+ * for (i=0; i < c; i++) {
+ * tevent_req_defer_callback(state->reqs[i], state->ev);
+ * tevent_req_done(state->reqs[i]);
+ * }
+ * }
+ * @endcode
+ *
+ * @param[in] req The finished request.
+ *
+ * @param[in] ev The tevent_context for the immediate event.
+ *
+ * @return The given request will be returned.
+ */
+void tevent_req_defer_callback(struct tevent_req *req,
+ struct tevent_context *ev);
+
+/**
* @brief Check if the given request is still in progress.
*
* It is typically used by sync wrapper functions.
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 9227f90..472beb5 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -142,6 +142,12 @@ struct tevent_req {
struct tevent_immediate *trigger;
/**
+ * @brief An event context which will be used to
+ * defer the _tevent_req_notify_callback().
+ */
+ struct tevent_context *defer_callback_ev;
+
+ /**
* @brief the timer event if tevent_req_set_endtime was used
*
*/
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index 92697b7..d8d0c5f 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -74,6 +74,7 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
talloc_free(req);
return NULL;
}
+ req->internal.defer_callback_ev = NULL;
data = talloc_zero_size(req, data_size);
if (data == NULL) {
@@ -91,6 +92,11 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
void _tevent_req_notify_callback(struct tevent_req *req, const char *location)
{
req->internal.finish_location = location;
+ if (req->internal.defer_callback_ev) {
+ (void)tevent_req_post(req, req->internal.defer_callback_ev);
+ req->internal.defer_callback_ev = NULL;
+ return;
+ }
if (req->async.fn != NULL) {
req->async.fn(req);
}
@@ -169,6 +175,12 @@ struct tevent_req *tevent_req_post(struct tevent_req *req,
return req;
}
+void tevent_req_defer_callback(struct tevent_req *req,
+ struct tevent_context *ev)
+{
+ req->internal.defer_callback_ev = ev;
+}
+
bool tevent_req_is_in_progress(struct tevent_req *req)
{
if (req->internal.state == TEVENT_REQ_IN_PROGRESS) {
diff --git a/lib/tevent/wscript b/lib/tevent/wscript
index 5dcd188..a655909 100644
--- a/lib/tevent/wscript
+++ b/lib/tevent/wscript
@@ -1,7 +1,7 @@
#!/usr/bin/env python
APPNAME = 'tevent'
-VERSION = '0.9.12'
+VERSION = '0.9.13'
blddir = 'bin'
--
Samba Shared Repository
More information about the samba-cvs
mailing list