return NULL;
}
- data = talloc_size(req, data_size);
+ data = talloc_zero_size(req, data_size);
if (data == NULL) {
talloc_free(req);
return NULL;
return req;
}
-static void tevent_req_finish(struct tevent_req *req,
- enum tevent_req_state state,
- const char *location)
+void _tevent_req_notify_callback(struct tevent_req *req, const char *location)
{
- req->internal.state = state;
req->internal.finish_location = location;
if (req->async.fn != NULL) {
req->async.fn(req);
}
}
+static void tevent_req_finish(struct tevent_req *req,
+ enum tevent_req_state state,
+ const char *location)
+{
+ req->internal.state = state;
+ _tevent_req_notify_callback(req, location);
+}
+
/**
* @brief An async request has successfully finished
* @param[in] req The finished request
*
- * async_req_done is to be used by implementors of async requests. When a
+ * tevent_req_done is to be used by implementors of async requests. When a
* request is successfully finished, this function calls the user's completion
* function.
*/
return req;
}
+/**
+ * @brief This function destroys the attached private data
+ * @param[in] req The request to poll
+ * @retval The boolean form of "is in progress".
+ *
+ * This function can be used to ask if the given request
+ * is still in progress.
+ *
+ * This function is typically used by sync wrapper functions.
+ */
bool tevent_req_is_in_progress(struct tevent_req *req)
{
if (req->internal.state == TEVENT_REQ_IN_PROGRESS) {
req->internal.state = TEVENT_REQ_RECEIVED;
}
+/**
+ * @brief This function destroys the attached private data
+ * @param[in] req The request to poll
+ * @param[in] ev The tevent_context to be used
+ * @retval If a critical error has happened in the
+ * tevent loop layer false is returned.
+ * Otherwise true is returned.
+ * This is not the return value of the given request!
+ *
+ * This function can be used to actively poll for the
+ * given request to finish.
+ *
+ * Note: this should only be used if the given tevent context
+ * was created by the caller, to avoid event loop nesting.
+ *
+ * This function is typically used by sync wrapper functions.
+ */
bool tevent_req_poll(struct tevent_req *req,
struct tevent_context *ev)
{
return req->data;
}
+/**
+ * @brief This function sets a print function for the given request
+ * @param[in] req The given request
+ * @param[in] fn A pointer to the print function
+ *
+ * This function can be used to setup a print function for the given request.
+ * This will be triggered if the tevent_req_print() function was
+ * called on the given request.
+ *
+ * Note: this function should only be used for debugging.
+ */
void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn)
{
req->private_print = fn;