tevent: Flow: store cancel function name in tevent_req
authorStefan Metzmacher <metze@samba.org>
Tue, 23 May 2023 04:38:27 +0000 (06:38 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 19 Jul 2023 08:02:33 +0000 (08:02 +0000)
Note the tevent-0.14.1.sigs changes will be reverted in
the 'tevent 0.15.0' commit.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Pavel Filipenský <pfilipensky@samba.org>
lib/tevent/ABI/tevent-0.14.1.sigs
lib/tevent/tevent.h
lib/tevent/tevent_internal.h
lib/tevent/tevent_req.c

index 908d7ffcf9d7043f5bdc355bf5523dc778c90247..9be4dafcd1e8b72cc8edd901a5ac553b1e29e018 100644 (file)
@@ -23,6 +23,7 @@ _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_req_set_cancel_fn: void (struct tevent_req *, tevent_req_cancel_fn, const char *)
 _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 *)
index 5958fa6213f75f872c1072d08eafe571cee361bc..b59c5792606863a511daa6e739e9330d6a0137bc 100644 (file)
@@ -1182,6 +1182,11 @@ typedef bool (*tevent_req_cancel_fn)(struct tevent_req *req);
  * @param[in]  fn       A pointer to the cancel function.
  */
 void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn);
+void _tevent_req_set_cancel_fn(struct tevent_req *req,
+                              tevent_req_cancel_fn fn,
+                              const char *fn_name);
+#define tevent_req_set_cancel_fn(req, fn) \
+       _tevent_req_set_cancel_fn(req, fn, #fn)
 
 #ifdef DOXYGEN
 /**
index db0c4a9d96537fcb155b033cff633549f5a56296..d8b07eba26dd4db905aef3ead3e2d21e979fcdf5 100644 (file)
@@ -75,7 +75,10 @@ struct tevent_req {
         * that is called when the tevent_req_cancel() function
         * was called.
         */
-       tevent_req_cancel_fn private_cancel;
+       struct {
+               tevent_req_cancel_fn fn;
+               const char *fn_name;
+       } private_cancel;
 
        /**
         * @brief A function to cleanup the request
index a677f437cdd8932e342870739b5d722b82bda559..0681f3c46d21f38edc34ea8161d74643fd2f3979 100644 (file)
@@ -28,6 +28,7 @@
 #include "tevent_util.h"
 
 #undef tevent_req_set_callback
+#undef tevent_req_set_cancel_fn
 
 char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
 {
@@ -306,7 +307,8 @@ void tevent_req_received(struct tevent_req *req)
        talloc_set_destructor(req, NULL);
 
        req->private_print = NULL;
-       req->private_cancel = NULL;
+       req->private_cancel.fn = NULL;
+       req->private_cancel.fn_name = NULL;
 
        TALLOC_FREE(req->internal.trigger);
        TALLOC_FREE(req->internal.timer);
@@ -413,16 +415,24 @@ void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn)
 
 void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn)
 {
-       req->private_cancel = fn;
+       _tevent_req_set_cancel_fn(req, fn, NULL);
+}
+
+void _tevent_req_set_cancel_fn(struct tevent_req *req,
+                              tevent_req_cancel_fn fn,
+                              const char *fn_name)
+{
+       req->private_cancel.fn = fn;
+       req->private_cancel.fn_name = fn != NULL ? fn_name : NULL;
 }
 
 bool _tevent_req_cancel(struct tevent_req *req, const char *location)
 {
-       if (req->private_cancel == NULL) {
+       if (req->private_cancel.fn == NULL) {
                return false;
        }
 
-       return req->private_cancel(req);
+       return req->private_cancel.fn(req);
 }
 
 void tevent_req_set_cleanup_fn(struct tevent_req *req, tevent_req_cleanup_fn fn)