changeset 19539:504104af673f

imap: Don't hang at ambiguous commands when they were pipelined already before login For example if all of these are sent in a single IP packet: a login user pass b select inbox c noop d unselect
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Tue, 05 Jan 2016 11:01:26 -0500
parents dfee8dea71b6
children f8d2dded6aa0
files src/imap/main.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/main.c	Mon Jan 04 14:34:01 2016 -0500
+++ b/src/imap/main.c	Tue Jan 05 11:01:26 2016 -0500
@@ -202,6 +202,13 @@
 	(void)client_handle_input(client);
 	o_stream_uncork(output);
 	o_stream_unref(&output);
+
+	/* we could have already handled LOGOUT, or we might need to continue
+	   pending ambigious commands. */
+	if (client->disconnected)
+		client_destroy(client, NULL);
+	else
+		client_continue_pending_input(client);
 }
 
 int client_create_from_input(const struct mail_storage_service_input *input,
@@ -280,6 +287,7 @@
 		const buffer_t *input_buf = t_base64_decode_str(input_base64);
 		client_add_input(client, input_buf->data, input_buf->used);
 	}
+	/* client may be destroyed now */
 }
 
 static void
@@ -314,12 +322,12 @@
 		master_service_client_connection_destroyed(master_service);
 		return;
 	}
-	client_add_input(client, login_client->data,
-			 login_client->auth_req.data_size);
-
 	flags = login_client->auth_req.flags;
 	if ((flags & MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION) != 0)
 		client->tls_compression = TRUE;
+	client_add_input(client, login_client->data,
+			 login_client->auth_req.data_size);
+	/* client may be destroyed now */
 }
 
 static void login_client_failed(const struct master_login_client *client,