dovecot-2.2: imap: Small code cleanup.

dovecot at dovecot.org dovecot at dovecot.org
Tue Apr 21 11:05:49 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/7a09ddcd62b4
changeset: 18431:7a09ddcd62b4
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Apr 21 14:03:52 2015 +0300
description:
imap: Small code cleanup.
Removed all the checks of CLIENT_COMMAND_STATE_DONE to command_exec()
itself.

diffstat:

 src/imap/cmd-append.c    |  2 +-
 src/imap/imap-client.c   |  7 +++----
 src/imap/imap-commands.c |  8 +++++---
 3 files changed, 9 insertions(+), 8 deletions(-)

diffs (66 lines):

diff -r 3ea5becbb56c -r 7a09ddcd62b4 src/imap/cmd-append.c
--- a/src/imap/cmd-append.c	Tue Apr 21 13:19:24 2015 +0300
+++ b/src/imap/cmd-append.c	Tue Apr 21 14:03:52 2015 +0300
@@ -114,7 +114,7 @@
 
 	o_stream_cork(client->output);
 	finished = command_exec(cmd);
-	if (!finished && cmd->state != CLIENT_COMMAND_STATE_DONE)
+	if (!finished)
 		(void)client_handle_unfinished_cmd(cmd);
 	else
 		client_command_free(&cmd);
diff -r 3ea5becbb56c -r 7a09ddcd62b4 src/imap/imap-client.c
--- a/src/imap/imap-client.c	Tue Apr 21 13:19:24 2015 +0300
+++ b/src/imap/imap-client.c	Tue Apr 21 14:03:52 2015 +0300
@@ -187,7 +187,7 @@
 
 	cmd_ret = !cmd->cancel || cmd->func == NULL ? TRUE :
 		command_exec(cmd);
-	if (!cmd_ret && cmd->state != CLIENT_COMMAND_STATE_DONE) {
+	if (!cmd_ret) {
 		if (cmd->client->output->closed)
 			i_panic("command didn't cancel itself: %s", cmd->name);
 	} else {
@@ -779,8 +779,7 @@
 
         if (cmd->func != NULL) {
 		/* command is being executed - continue it */
-		if (command_exec(cmd) ||
-		    cmd->state == CLIENT_COMMAND_STATE_DONE) {
+		if (command_exec(cmd)) {
 			/* command execution was finished */
 			client_command_free(&cmd);
 			client_add_missing_io(client);
@@ -959,7 +958,7 @@
 	bool finished;
 
 	/* continue processing command */
-	finished = command_exec(cmd) || cmd->state == CLIENT_COMMAND_STATE_DONE;
+	finished = command_exec(cmd);
 
 	if (!finished)
 		(void)client_handle_unfinished_cmd(cmd);
diff -r 3ea5becbb56c -r 7a09ddcd62b4 src/imap/imap-commands.c
--- a/src/imap/imap-commands.c	Tue Apr 21 13:19:24 2015 +0300
+++ b/src/imap/imap-commands.c	Tue Apr 21 14:03:52 2015 +0300
@@ -151,14 +151,16 @@
 bool command_exec(struct client_command_context *cmd)
 {
 	const struct command_hook *hook;
-	bool ret;
+	bool finished;
 
 	array_foreach(&command_hooks, hook)
 		hook->pre(cmd);
-	ret = cmd->func(cmd);
+	finished = cmd->func(cmd);
 	array_foreach(&command_hooks, hook)
 		hook->post(cmd);
-	return ret;
+	if (cmd->state == CLIENT_COMMAND_STATE_DONE)
+		finished = TRUE;
+	return finished;
 }
 
 static int command_cmp(const struct command *c1, const struct command *c2)


More information about the dovecot-cvs mailing list