]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: event_pop_global() - Assert-crash if trying to pop ioloop context's global root...
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 21 Apr 2021 13:55:57 +0000 (16:55 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 29 Sep 2021 10:09:58 +0000 (10:09 +0000)
This makes it easier to debug bugs.

src/lib/ioloop-private.h
src/lib/ioloop.c
src/lib/lib-event.c

index b7b2aafece7835f56f7e8f21fab7ec86d7ae3eab..799ca4d6d53d65f06aa96a6148fe1780b2eab8ac 100644 (file)
@@ -124,4 +124,6 @@ void io_loop_handler_deinit(struct ioloop *ioloop);
 void io_loop_notify_remove(struct io *io);
 void io_loop_notify_handler_deinit(struct ioloop *ioloop);
 
+struct event *io_loop_get_active_global_root(void);
+
 #endif
index c1db61a2f23217b7d4eb1867c25a12a3a7dbeb47..39b171329aeff204a45fd1ac300cf3fdc4b7091b 100644 (file)
@@ -1374,3 +1374,12 @@ uint64_t io_wait_timer_get_usecs(struct io_wait_timer *timer)
 {
        return timer->usecs;
 }
+
+struct event *io_loop_get_active_global_root(void)
+{
+       if (current_ioloop == NULL)
+               return NULL;
+       if (current_ioloop->cur_ctx == NULL)
+               return NULL;
+       return current_ioloop->cur_ctx->root_global_event;
+}
index f1c45cbe5c24f9431582716f0b9cd74fc604251f..809914af4e8b6e59f55132a051f3035b284e0137 100644 (file)
@@ -8,7 +8,7 @@
 #include "time-util.h"
 #include "str.h"
 #include "strescape.h"
-#include "ioloop.h"
+#include "ioloop-private.h"
 
 enum event_code {
        EVENT_CODE_ALWAYS_LOG_SOURCE    = 'a',
@@ -499,6 +499,10 @@ struct event *event_pop_global(struct event *event)
 {
        i_assert(event != NULL);
        i_assert(event == current_global_event);
+       /* If the active context's root event is popped, we'll assert-crash
+          later on when deactivating the context and the root event no longer
+          exists. */
+       i_assert(event != io_loop_get_active_global_root());
 
        if (!array_is_created(&global_event_stack) ||
            array_count(&global_event_stack) == 0)