From: Timo Sirainen Date: Wed, 7 Sep 2016 08:52:00 +0000 (+0300) Subject: imap: Avoid wrongly assert-crashing in client_check_command_hangs() X-Git-Tag: 2.3.0.rc1~3067 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd9cf45dcf9fcabc89e156117c4dcf464ec4eb85;p=thirdparty%2Fdovecot%2Fcore.git imap: Avoid wrongly assert-crashing in client_check_command_hangs() Fixes assert: Panic: file imap-client.c: line 837 (client_check_command_hangs): assertion failed: (client->io != NULL) --- diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 3327788857..806e662c42 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -853,7 +853,14 @@ static void client_check_command_hangs(struct client *client) for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) { switch (cmd->state) { case CLIENT_COMMAND_STATE_WAIT_INPUT: - i_assert(client->io != NULL); + /* We need to be reading input for this command. + However, if there is already an output lock for + another command we'll wait for it to finish first. + This is needed because if there are any literals + we'd need to send "+ OK" responses. */ + i_assert(client->io != NULL || + (client->output_cmd_lock != NULL && + client->output_cmd_lock != client->input_lock)); unfinished_count++; break; case CLIENT_COMMAND_STATE_WAIT_OUTPUT: @@ -1056,6 +1063,8 @@ static bool client_handle_next_command(struct client *client, bool *remove_io_r) if (client->input_lock != NULL) { if (client->input_lock->state == CLIENT_COMMAND_STATE_WAIT_UNAMBIGUITY || + /* we can't send literal "+ OK" replies if output is + locked by another command. */ (client->output_cmd_lock != NULL && client->output_cmd_lock != client->input_lock)) { *remove_io_r = TRUE;