lib/util: install a tevent_abort callback using smb_panic()
authorStefan Metzmacher <metze@samba.org>
Wed, 9 Nov 2022 13:05:59 +0000 (14:05 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 18 Jan 2023 16:26:36 +0000 (16:26 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Pavel Filipenský <pfilipen@redhat.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/util/tevent_debug.c

index 48f65299c5d18d7e1a593e546efb408b24025e90..bc3dd0ca9448e33b78ee3c8c41adda9414f6ac2b 100644 (file)
@@ -68,9 +68,25 @@ static void samba_tevent_debug(void *context,
        }
 }
 
+static void samba_tevent_abort_fn(const char *reason)
+{
+       smb_panic(reason);
+}
+
+static void samba_tevent_setup_abort_fn(void)
+{
+       static bool abort_fn_done;
+
+       if (!abort_fn_done) {
+               tevent_set_abort_fn(samba_tevent_abort_fn);
+               abort_fn_done = true;
+       }
+}
+
 void samba_tevent_set_debug(struct tevent_context *ev, const char *name)
 {
        void *p = discard_const(name);
+       samba_tevent_setup_abort_fn();
        tevent_set_debug(ev, samba_tevent_debug, p);
 }
 
@@ -78,6 +94,8 @@ struct tevent_context *samba_tevent_context_init(TALLOC_CTX *mem_ctx)
 {
        struct tevent_context *ev;
 
+       samba_tevent_setup_abort_fn();
+
        ev = tevent_context_init(mem_ctx);
        if (ev) {
                samba_tevent_set_debug(ev, NULL);