]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
dsync: ioloop context shouldn't deactivate after ioloop has run
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 19 Apr 2021 21:05:23 +0000 (00:05 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 29 Sep 2021 10:09:58 +0000 (10:09 +0000)
Normally that is wanted, but dsync reuses the same ioloop as the parent
doveadm connection, so after the inner io_loop_run() it's still running
in the doveadm connection's io callback.

Without this all the global events will be popped out, and the following
global event change commit will cause crashes.

src/doveadm/doveadm-dsync.c

index 67412e4631e69dcc56fef97810093a4879013d51..226c8bfb074853ccdf4224b0f402dcafb77053b7 100644 (file)
@@ -462,6 +462,9 @@ static void cmd_dsync_wait_remote(struct dsync_cmd_context *ctx)
        io_loop_run(current_ioloop);
        timeout_remove(&to);
 
+       /* io_loop_run() deactivates the context - put it back */
+       mail_storage_service_io_activate_user(ctx->ctx.cur_service_user);
+
        if (!ctx->exited) {
                i_error("Remote command process isn't dying, killing it");
                if (kill(ctx->remote_pid, SIGKILL) < 0 && errno != ESRCH) {
@@ -704,6 +707,8 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
                /* fall through */
        case DSYNC_RUN_TYPE_STREAM:
                cmd_dsync_run_remote(user);
+               /* io_loop_run() deactivates the context - put it back */
+               mail_storage_service_io_activate_user(ctx->ctx.cur_service_user);
                break;
        }
 
@@ -1239,6 +1244,8 @@ cmd_dsync_server_run(struct doveadm_mail_cmd_context *_ctx,
                                       doveadm_settings->dsync_alt_char[0]);
 
        io_loop_run(current_ioloop);
+       /* io_loop_run() deactivates the context - put it back */
+       mail_storage_service_io_activate_user(ctx->ctx.cur_service_user);
 
        if (ctx->replicator_notify) {
                state_str = t_str_new(128);