From 848bc013ae3fd85ee29a39c1e7a44882e58dba73 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 18 Nov 2015 12:39:13 +0200 Subject: [PATCH] imap: When disconnected during FETCH, include the last byte counts in disconnection log message. --- src/imap/cmd-fetch.c | 10 ++++++++-- src/imap/imap-client.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/imap/cmd-fetch.c b/src/imap/cmd-fetch.c index 96c9f62f0f..d19eaf3233 100644 --- a/src/imap/cmd-fetch.c +++ b/src/imap/cmd-fetch.c @@ -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); diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index d8af0b247d..e802c2967a 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -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); -- 2.47.3