dovecot-2.1: imapc: Fixes to sending commands.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 9 18:56:12 EEST 2011
details: http://hg.dovecot.org/dovecot-2.1/rev/256b9b32b242
changeset: 13623:256b9b32b242
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 09 18:25:18 2011 +0300
description:
imapc: Fixes to sending commands.
diffstat:
src/lib-imap-client/imapc-connection.c | 38 +++++++++++++++++----------------
1 files changed, 20 insertions(+), 18 deletions(-)
diffs (82 lines):
diff -r 305ca9c93dd7 -r 256b9b32b242 src/lib-imap-client/imapc-connection.c
--- a/src/lib-imap-client/imapc-connection.c Sun Oct 09 17:15:31 2011 +0300
+++ b/src/lib-imap-client/imapc-connection.c Sun Oct 09 18:25:18 2011 +0300
@@ -873,6 +873,9 @@
/* "+ idling" reply for IDLE command */
conn->idle_plus_waiting = FALSE;
conn->idling = TRUE;
+ /* no timeouting while IDLEing */
+ if (conn->to != NULL)
+ timeout_remove(&conn->to);
} else if (cmds_count > 0 && cmds[0]->wait_for_literal) {
/* reply for literal */
cmds[0]->wait_for_literal = FALSE;
@@ -1372,8 +1375,8 @@
return TRUE;
}
-static void imapc_command_send_done(struct imapc_connection *conn,
- struct imapc_command *cmd)
+static void imapc_command_send_finished(struct imapc_connection *conn,
+ struct imapc_command *cmd)
{
if (cmd->idle)
conn->idle_plus_waiting = TRUE;
@@ -1487,6 +1490,7 @@
array_delete(&conn->cmd_send_queue, 0, 1);
imapc_command_reply_free(cmd, &reply);
+ imapc_command_send_more(conn);
return;
}
@@ -1524,7 +1528,7 @@
if (cmd->send_pos == cmd->data->used) {
i_assert(!array_is_created(&cmd->streams) ||
array_count(&cmd->streams) == 0);
- imapc_command_send_done(conn, cmd);
+ imapc_command_send_finished(conn, cmd);
} else {
cmd->wait_for_literal = TRUE;
}
@@ -1556,27 +1560,25 @@
struct imapc_connection *conn = cmd->conn;
imapc_connection_send_idle_done(conn);
- switch (conn->state) {
- case IMAPC_CONNECTION_STATE_AUTHENTICATING:
+
+ if ((cmd->flags & IMAPC_COMMAND_FLAG_PRELOGIN) != 0 &&
+ conn->state == IMAPC_CONNECTION_STATE_AUTHENTICATING) {
+ /* pre-login commands get inserted before everything else */
array_insert(&conn->cmd_send_queue, 0, &cmd, 1);
imapc_command_send_more(conn);
- break;
- case IMAPC_CONNECTION_STATE_DONE:
- if (cmd->idle) {
- if (conn->to != NULL)
- timeout_remove(&conn->to);
- } else if (conn->to == NULL) {
+ return;
+ }
+
+ if (conn->state == IMAPC_CONNECTION_STATE_DONE) {
+ /* add timeout for commands if there's not one yet
+ (pre-login has its own timeout) */
+ if (conn->to == NULL) {
conn->to = timeout_add(IMAPC_COMMAND_TIMEOUT_MSECS,
imapc_command_timeout, conn);
}
-
- array_append(&conn->cmd_send_queue, &cmd, 1);
- imapc_command_send_more(conn);
- break;
- default:
- array_append(&conn->cmd_send_queue, &cmd, 1);
- break;
}
+ array_append(&conn->cmd_send_queue, &cmd, 1);
+ imapc_command_send_more(conn);
}
static int imapc_connection_output(struct imapc_connection *conn)
More information about the dovecot-cvs
mailing list