dovecot-2.2: imap: Added assert to make sure client_command_cont...

dovecot at dovecot.org dovecot at dovecot.org
Wed Dec 9 10:43:44 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/4535ac0b8ab1
changeset: 19495:4535ac0b8ab1
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Dec 09 12:43:18 2015 +0200
description:
imap: Added assert to make sure client_command_context isn't freed too early.

diffstat:

 src/imap/imap-client.c   |  1 +
 src/imap/imap-client.h   |  1 +
 src/imap/imap-commands.c |  4 ++++
 3 files changed, 6 insertions(+), 0 deletions(-)

diffs (46 lines):

diff -r 63706ee7f49e -r 4535ac0b8ab1 src/imap/imap-client.c
--- 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
diff -r 63706ee7f49e -r 4535ac0b8ab1 src/imap/imap-client.h
--- 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 {
diff -r 63706ee7f49e -r 4535ac0b8ab1 src/imap/imap-commands.c
--- 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;
 


More information about the dovecot-cvs mailing list