]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: client: Properly manage command timeout during transaction.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 29 Sep 2018 18:54:03 +0000 (20:54 +0200)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 10 Oct 2018 09:49:07 +0000 (09:49 +0000)
src/lib-smtp/smtp-client-command.c
src/lib-smtp/smtp-client-connection.c

index 546af8992b7b54156001f78d4aa54f2355060031..debeceeac2a231aa67a8f6fe666ee76522227f0e 100644 (file)
@@ -522,7 +522,7 @@ smtp_client_command_send_stream(struct smtp_client_command *cmd)
        i_unreached();
 }
 
-int smtp_client_command_send_more(struct smtp_client_connection *conn)
+static int smtp_client_command_do_send_more(struct smtp_client_connection *conn)
 {
        struct smtp_client_command *cmd;
        const char *data;
@@ -621,6 +621,17 @@ int smtp_client_command_send_more(struct smtp_client_connection *conn)
        return 0;
 }
 
+int smtp_client_command_send_more(struct smtp_client_connection *conn)
+{
+       int ret;
+
+       if ((ret=smtp_client_command_do_send_more(conn)) < 0)
+               return -1;
+
+       smtp_client_connection_update_cmd_timeout(conn);
+       return ret;
+}
+
 static void
 smtp_client_command_disconnected(struct smtp_client_connection *conn)
 {
index 3e48e8473abe620a203791eb0cfbc9970a48a210..fc553279ddcbb42103c4731a8e0ef9e4c258a2e2 100644 (file)
@@ -228,7 +228,7 @@ void smtp_client_connection_start_cmd_timeout(
 {
        unsigned int msecs = conn->set.command_timeout_msecs;
 
-       if (conn->state != SMTP_CLIENT_CONNECTION_STATE_READY) {
+       if (conn->state < SMTP_CLIENT_CONNECTION_STATE_READY) {
                /* pre-login uses connect timeout */
                return;
        }
@@ -237,8 +237,7 @@ void smtp_client_connection_start_cmd_timeout(
                timeout_remove(&conn->to_commands);
                return;
        }
-       if (conn->cmd_wait_list_head == NULL &&
-               conn->cmd_send_queue_head == NULL) {
+       if (conn->cmd_wait_list_head == NULL && !conn->sending_command) {
                /* no commands pending */
                timeout_remove(&conn->to_commands);
                return;
@@ -256,7 +255,7 @@ void smtp_client_connection_update_cmd_timeout(
 {
        unsigned int msecs = conn->set.command_timeout_msecs;
 
-       if (conn->state != SMTP_CLIENT_CONNECTION_STATE_READY) {
+       if (conn->state < SMTP_CLIENT_CONNECTION_STATE_READY) {
                /* pre-login uses connect timeout */
                return;
        }
@@ -266,8 +265,7 @@ void smtp_client_connection_update_cmd_timeout(
                return;
        }
 
-       if (conn->cmd_wait_list_head == NULL &&
-               conn->cmd_send_queue_head == NULL) {
+       if (conn->cmd_wait_list_head == NULL && !conn->sending_command) {
                if (conn->to_commands != NULL) {
                        smtp_client_connection_debug(conn,
                                "No commands pending; stop timeout");