tevent: add tevent_req_received() function
authorStefan Metzmacher <metze@samba.org>
Tue, 10 Mar 2009 12:54:57 +0000 (13:54 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 10 Mar 2009 15:44:44 +0000 (16:44 +0100)
This function can be called as last action of a _recv()
function, it destroys the data attached to the tevent_req.

metze

lib/tevent/tevent.h
lib/tevent/tevent_internal.h
lib/tevent/tevent_req.c

index 5089d18ec21381ccf1179894dc99e22e72d67e77..8ae9eaf54579252cbc6c5387d5b6b724621e6f1c 100644 (file)
@@ -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);
index fa73b22a48bf8146041f18e57a7378beff19ae29..5a645ecb6082d1e5ddbce1ef140283cc437ed16b 100644 (file)
@@ -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.
         */
index 9b3e00ec8fa7bb97a982726a42ca7615a6849612..3832088b34cc24601a771a1cf2af8ff366244ee2 100644 (file)
@@ -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)
 {