]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Add io_loop_get_root()
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 17 Sep 2019 16:52:14 +0000 (19:52 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 23 Sep 2019 08:45:30 +0000 (11:45 +0300)
src/lib/ioloop.c
src/lib/ioloop.h

index 64fdb54a2965346875b9ce301a308bb52976f8a7..7482970aa9c88192e8a6acf65b2c9eefcc819320 100644 (file)
@@ -947,6 +947,15 @@ void io_loop_set_current(struct ioloop *ioloop)
        }
 }
 
+struct ioloop *io_loop_get_root(void)
+{
+       struct ioloop *ioloop = current_ioloop;
+
+       while (ioloop->prev != NULL)
+               ioloop = ioloop->prev;
+       return ioloop;
+}
+
 void io_loop_add_switch_callback(io_switch_callback_t *callback)
 {
        if (!array_is_created(&io_switch_callbacks)) {
index 9f60b2f9d615d1376550f68d4c6001eb37d4dc6c..c1f9aa4853095d64cbccb2e71f995e3f8851612e 100644 (file)
@@ -201,6 +201,8 @@ void io_loop_set_time_moved_callback(struct ioloop *ioloop,
 
 /* Change the current_ioloop. */
 void io_loop_set_current(struct ioloop *ioloop);
+/* Return the root ioloop. */
+struct ioloop *io_loop_get_root(void);
 /* Call the callback whenever ioloop is changed. */
 void io_loop_add_switch_callback(io_switch_callback_t *callback);
 void io_loop_remove_switch_callback(io_switch_callback_t *callback);