From: Timo Sirainen Date: Wed, 9 Aug 2017 10:23:36 +0000 (+0300) Subject: push-notification: Switch to main ioloop while calling drivers' deinit/cleanup callbacks X-Git-Tag: 2.2.32.rc1~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=586c11a1bb170a73de237becb36c5b58d69a8c84;p=thirdparty%2Fdovecot%2Fcore.git push-notification: Switch to main ioloop while calling drivers' deinit/cleanup callbacks Continues a44595f7b1afc7ccbd8653598753b32899d01c76 to other functions. For example the OX backend would call http_client_wait(), which would move the I/Os and timeouts to the current ioloop, which might not be main_ioloop always. When that ioloop gets destroyed, I/O and timeout leaks are logged and eventually the process crashes when calling http_client_deinit() in cleanup() (this would happen later for another mail_user). --- diff --git a/src/plugins/push-notification/push-notification-plugin.c b/src/plugins/push-notification/push-notification-plugin.c index 407e37b6ff..c2b16d0e07 100644 --- a/src/plugins/push-notification/push-notification-plugin.c +++ b/src/plugins/push-notification/push-notification-plugin.c @@ -275,6 +275,11 @@ static void push_notification_user_deinit(struct mail_user *user) struct push_notification_user *puser = PUSH_NOTIFICATION_USER_CONTEXT(user); struct push_notification_driver_list *dlist = puser->driverlist; struct push_notification_driver_user **duser; + struct ioloop *prev_ioloop = current_ioloop; + + /* Make sure we're in the main ioloop, so if the deinit/cleanup moves any + I/Os or timeouts they won't get moved to some temporary ioloop. */ + io_loop_set_current(main_ioloop); array_foreach_modifiable(&dlist->drivers, duser) { if ((*duser)->driver->v.deinit != NULL) { @@ -285,6 +290,8 @@ static void push_notification_user_deinit(struct mail_user *user) (*duser)->driver->v.cleanup(); } } + io_loop_set_current(prev_ioloop); + puser->module_ctx.super.deinit(user); }