changeset 19387:b638e19d3bd4

imap: When disconnected during FETCH, include the last byte counts in disconnection log message.
author Timo Sirainen <tss@iki.fi>
date Wed, 18 Nov 2015 12:39:13 +0200
parents f8dcf8b91282
children 3d209e0982bf
files src/imap/cmd-fetch.c src/imap/imap-client.c
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/cmd-fetch.c	Tue Nov 17 19:02:13 2015 +0200
+++ b/src/imap/cmd-fetch.c	Wed Nov 18 12:39:13 2015 +0200
@@ -192,8 +192,14 @@
 		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);
--- a/src/imap/imap-client.c	Tue Nov 17 19:02:13 2015 +0200
+++ b/src/imap/imap-client.c	Wed Nov 18 12:39:13 2015 +0200
@@ -1135,7 +1135,7 @@
 
 	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);