summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-03-10 13:54:57 +0100
committerStefan Metzmacher <metze@samba.org>2009-03-10 16:44:44 +0100
commit09d1b2324cf02c20daa005e6f5d55dc107303af7 (patch)
tree0560b59d1abd01358b7a73c2a6f874c7bf86c86d /lib
parent97cccb22194380ce84bf6188df90e2438f1176db (diff)
downloadsamba-09d1b2324cf02c20daa005e6f5d55dc107303af7.tar.gz
samba-09d1b2324cf02c20daa005e6f5d55dc107303af7.tar.bz2
samba-09d1b2324cf02c20daa005e6f5d55dc107303af7.zip
tevent: add tevent_req_received() function
This function can be called as last action of a _recv() function, it destroys the data attached to the tevent_req. metze
Diffstat (limited to 'lib')
-rw-r--r--lib/tevent/tevent.h8
-rw-r--r--lib/tevent/tevent_internal.h2
-rw-r--r--lib/tevent/tevent_req.c21
3 files changed, 29 insertions, 2 deletions
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 5089d18ec2..8ae9eaf545 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -165,7 +165,11 @@ enum tevent_req_state {
/**
* No memory in between
*/
- TEVENT_REQ_NO_MEMORY
+ TEVENT_REQ_NO_MEMORY,
+ /**
+ * the request is already received by the caller
+ */
+ TEVENT_REQ_RECEIVED
};
/**
@@ -238,6 +242,8 @@ bool tevent_req_is_error(struct tevent_req *req,
enum tevent_req_state *state,
uint64_t *error);
+void tevent_req_received(struct tevent_req *req);
+
struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct timeval wakeup_time);
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index fa73b22a48..5a645ecb60 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -56,7 +56,7 @@ struct tevent_req {
/**
* @brief A function to overwrite the default print function
*
- * The implementation doing the work may want to imeplement a
+ * The implementation doing the work may want to implement a
* custom function to print the text representation of the async
* request.
*/
diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c
index 9b3e00ec8f..3832088b34 100644
--- a/lib/tevent/tevent_req.c
+++ b/lib/tevent/tevent_req.c
@@ -256,6 +256,27 @@ bool tevent_req_is_in_progress(struct tevent_req *req)
return false;
}
+/**
+ * @brief This function destroys the attached private data
+ * @param[in] req The finished request
+ *
+ * This function can be called as last action of a _recv()
+ * function, it destroys the data attached to the tevent_req.
+ */
+void tevent_req_received(struct tevent_req *req)
+{
+ talloc_free(req->data);
+ req->data = NULL;
+ req->private_print = NULL;
+
+ talloc_free(req->internal.trigger);
+ req->internal.trigger = NULL;
+ talloc_free(req->internal.timer);
+ req->internal.timer = NULL;
+
+ req->internal.state = TEVENT_REQ_RECEIVED;
+}
+
bool tevent_req_poll(struct tevent_req *req,
struct tevent_context *ev)
{