diff --git a/src/imap/imap-client.c b/src/imap/imap-client.c index 3934634475..07cacd4669 100644 --- a/src/imap/imap-client.c +++ b/src/imap/imap-client.c @@ -748,6 +748,7 @@ void client_command_free(struct client_command_context **_cmd) *_cmd = NULL; + i_assert(!cmd->executing); i_assert(client->output_cmd_lock == NULL); /* reset input idle time because command output might have taken a diff --git a/src/imap/imap-client.h b/src/imap/imap-client.h index 1a7a2e6ea4..36271de26b 100644 --- a/src/imap/imap-client.h +++ b/src/imap/imap-client.h @@ -93,6 +93,7 @@ struct client_command_context { unsigned int search_save_result_used:1; /* command uses search save */ unsigned int temp_executed:1; /* temporary execution state tracking */ unsigned int tagline_sent:1; + unsigned int executing:1; }; struct imap_client_vfuncs { diff --git a/src/imap/imap-commands.c b/src/imap/imap-commands.c index 9c5f271c1a..67221ad80b 100644 --- a/src/imap/imap-commands.c +++ b/src/imap/imap-commands.c @@ -159,16 +159,20 @@ bool command_exec(struct client_command_context *cmd) struct timeval cmd_start_timeval; uint64_t cmd_start_bytes_in, cmd_start_bytes_out; + i_assert(!cmd->executing); + io_loop_time_refresh(); cmd_start_timeval = ioloop_timeval; cmd_start_bytes_in = i_stream_get_absolute_offset(cmd->client->input); cmd_start_bytes_out = cmd->client->output->offset; + cmd->executing = TRUE; array_foreach(&command_hooks, hook) hook->pre(cmd); finished = cmd->func(cmd); array_foreach(&command_hooks, hook) hook->post(cmd); + cmd->executing = FALSE; if (cmd->state == CLIENT_COMMAND_STATE_DONE) finished = TRUE;