]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Fixed previous idle change more correctly.
authorTimo Sirainen <tss@iki.fi>
Mon, 31 May 2010 18:28:04 +0000 (19:28 +0100)
committerTimo Sirainen <tss@iki.fi>
Mon, 31 May 2010 18:28:04 +0000 (19:28 +0100)
The previous way could have crashed in some situations.

--HG--
branch : HEAD

src/imap/cmd-idle.c

index f6397bf7185a3cbec40c153defc2de27f03b86ed..738ea63b79fee2651268fe99d189d0df89c6e2fb 100644 (file)
@@ -127,11 +127,15 @@ static void idle_sync_now(struct mailbox *box, struct cmd_idle_context *ctx)
 
 static void idle_callback(struct mailbox *box, struct cmd_idle_context *ctx)
 {
+       struct client *client = ctx->client;
+
        if (ctx->sync_ctx != NULL)
                ctx->sync_pending = TRUE;
        else {
                ctx->manual_cork = TRUE;
                idle_sync_now(box, ctx);
+               if (client->disconnected)
+                       client_destroy(client, NULL);
        }
 }
 
@@ -207,7 +211,6 @@ static bool cmd_idle_continue(struct client_command_context *cmd)
 
        if (client->output->closed) {
                idle_finish(ctx, FALSE, FALSE);
-               client_destroy(client, NULL);
                return TRUE;
        }
        if (client->io == NULL) {