From: Pavel Filipenský Date: Mon, 24 Apr 2023 13:04:06 +0000 (+0200) Subject: tevent: Flow: store callback function name in tevent_req X-Git-Tag: tevent-0.15.0~13 X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=deec9994eb873ad42932645361dd3eedcc351a09;p=samba.git tevent: Flow: store callback function name in tevent_req Note the tevent-0.14.1.sigs changes will be reverted in the 'tevent 0.15.0' commit. Signed-off-by: Pavel Filipenský Reviewed-by: Stefan Metzmacher --- diff --git a/lib/tevent/ABI/tevent-0.14.1.sigs b/lib/tevent/ABI/tevent-0.14.1.sigs index 557f2d3619d..1dcb4251793 100644 --- a/lib/tevent/ABI/tevent-0.14.1.sigs +++ b/lib/tevent/ABI/tevent-0.14.1.sigs @@ -19,6 +19,7 @@ _tevent_req_error: bool (struct tevent_req *, uint64_t, const char *) _tevent_req_nomem: bool (const void *, struct tevent_req *, const char *) _tevent_req_notify_callback: void (struct tevent_req *, const char *) _tevent_req_oom: void (struct tevent_req *, const char *) +_tevent_req_set_callback: void (struct tevent_req *, tevent_req_fn, const char *, void *) _tevent_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *) _tevent_threaded_schedule_immediate: void (struct tevent_threaded_context *, struct tevent_immediate *, tevent_immediate_handler_t, void *, const char *, const char *) tevent_abort: void (struct tevent_context *, const char *) diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h index 514e127cc38..7f442fe3904 100644 --- a/lib/tevent/tevent.h +++ b/lib/tevent/tevent.h @@ -1019,6 +1019,13 @@ typedef void (*tevent_req_fn)(struct tevent_req *subreq); * callback. */ void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt); +void _tevent_req_set_callback(struct tevent_req *req, + tevent_req_fn fn, + const char *fn_name, + void *pvt); + +#define tevent_req_set_callback(req, fn, pvt) \ + _tevent_req_set_callback(req, fn, #fn, pvt) #ifdef DOXYGEN /** diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h index e6853d148ee..db0c4a9d965 100644 --- a/lib/tevent/tevent_internal.h +++ b/lib/tevent/tevent_internal.h @@ -44,6 +44,10 @@ struct tevent_req { * @brief Private data for the completion function */ void *private_data; + /** + * @brief The completion function name, for flow tracing. + */ + const char *fn_name; } async; /** diff --git a/lib/tevent/tevent_req.c b/lib/tevent/tevent_req.c index 10e9812ad0f..a677f437cdd 100644 --- a/lib/tevent/tevent_req.c +++ b/lib/tevent/tevent_req.c @@ -27,6 +27,8 @@ #include "tevent_internal.h" #include "tevent_util.h" +#undef tevent_req_set_callback + char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx) { return talloc_asprintf(mem_ctx, @@ -380,8 +382,17 @@ void tevent_req_reset_endtime(struct tevent_req *req) } void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt) +{ + return _tevent_req_set_callback(req, fn, NULL, pvt); +} + +void _tevent_req_set_callback(struct tevent_req *req, + tevent_req_fn fn, + const char *fn_name, + void *pvt) { req->async.fn = fn; + req->async.fn_name = fn_name; req->async.private_data = pvt; }