]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: When disconnected during FETCH, include the last byte counts in disconnection...
authorTimo Sirainen <tss@iki.fi>
Wed, 18 Nov 2015 10:39:13 +0000 (12:39 +0200)
committerTimo Sirainen <tss@iki.fi>
Wed, 18 Nov 2015 10:39:13 +0000 (12:39 +0200)
src/imap/cmd-fetch.c
src/imap/imap-client.c

index 96c9f62f0fe9a375af7016c657074af70e27560f..d19eaf3233294075ecff67ee7515066dea3ac35e 100644 (file)
@@ -192,8 +192,14 @@ static bool cmd_fetch_finish(struct imap_fetch_context *ctx,
                const char *errstr;
 
                if (cmd->client->output->closed) {
-                       client_disconnect(cmd->client, NULL);
-                       return TRUE;
+                       /* If we're canceling we need to finish this command
+                          or we'll assert crash. But normally we want to
+                          return FALSE so that the disconnect message logs
+                          about this fetch command and that these latest
+                          output bytes are included in it (which wouldn't
+                          happen if we called client_disconnect() here
+                          directly). */
+                       return cmd->cancel;
                }
 
                errstr = mailbox_get_last_error(cmd->client->mailbox, &error);
index d8af0b247ddb7a8c2d1c2c9530b49f9cc4522f9b..e802c2967a16d0e901262834b5c7531299f9a0eb 100644 (file)
@@ -1135,7 +1135,7 @@ int client_output(struct client *client)
 
        o_stream_uncork(client->output);
        imap_refresh_proctitle();
-       if (client->disconnected)
+       if (client->output->closed)
                client_destroy(client, NULL);
        else
                client_continue_pending_input(client);