changeset 19495:4535ac0b8ab1

imap: Added assert to make sure client_command_context isn't freed too early.
author Timo Sirainen <tss@iki.fi>
date Wed, 09 Dec 2015 12:43:18 +0200
parents 63706ee7f49e
children 13afb0912164
files src/imap/imap-client.c src/imap/imap-client.h src/imap/imap-commands.c
diffstat 3 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/imap/imap-client.c	Wed Dec 09 10:49:22 2015 +0200
+++ b/src/imap/imap-client.c	Wed Dec 09 12:43:18 2015 +0200
@@ -748,6 +748,7 @@
 
 	*_cmd = NULL;
 
+	i_assert(!cmd->executing);
 	i_assert(client->output_cmd_lock == NULL);
 
 	/* reset input idle time because command output might have taken a
--- a/src/imap/imap-client.h	Wed Dec 09 10:49:22 2015 +0200
+++ b/src/imap/imap-client.h	Wed Dec 09 12:43:18 2015 +0200
@@ -93,6 +93,7 @@
 	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 {
--- a/src/imap/imap-commands.c	Wed Dec 09 10:49:22 2015 +0200
+++ b/src/imap/imap-commands.c	Wed Dec 09 12:43:18 2015 +0200
@@ -159,16 +159,20 @@
 	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;