]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-server-connection - Move pipeline limit check to separate function.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Wed, 24 Jun 2020 09:13:59 +0000 (11:13 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 7 Oct 2020 11:45:27 +0000 (11:45 +0000)
src/lib-smtp/smtp-server-connection.c

index 3cd79cf0a64b934a03b5d866b4a0b0919bcaed4e..3a81195d06a15bfaccd489c1bf8088dcc7768769 100644 (file)
@@ -57,6 +57,20 @@ smtp_server_connection_get_stats(struct smtp_server_connection *conn)
        return &conn->stats;
 }
 
+static bool
+smtp_server_connection_check_pipeline(struct smtp_server_connection *conn)
+{
+       if (conn->command_queue_count >
+           conn->server->set.max_pipelined_commands) {
+               e_debug(conn->event, "Command pipeline is full "
+                       "(pipelined commands %u > limit %u)",
+                       conn->command_queue_count,
+                       conn->server->set.max_pipelined_commands);
+               return FALSE;
+       }
+       return TRUE;
+}
+
 void smtp_server_connection_input_halt(struct smtp_server_connection *conn)
 {
        connection_input_halt(&conn->conn);
@@ -72,8 +86,7 @@ void smtp_server_connection_input_resume(struct smtp_server_connection *conn)
                if (conn->input_locked || conn->input_broken ||
                        conn->disconnected)
                        return;
-               if (conn->command_queue_count >
-                       conn->server->set.max_pipelined_commands)
+               if (!smtp_server_connection_check_pipeline(conn))
                        return;
 
                /* Is queued command still blocking input? */
@@ -449,8 +462,7 @@ smtp_server_connection_handle_input(struct smtp_server_connection *conn)
                        if (conn->closing)
                                break;
 
-                       if (conn->command_queue_count >=
-                               conn->server->set.max_pipelined_commands) {
+                       if (!smtp_server_connection_check_pipeline(conn)) {
                                smtp_server_connection_input_halt(conn);
                                return;
                        }
@@ -577,8 +589,7 @@ static void smtp_server_connection_input(struct connection *_conn)
        i_assert(!conn->halted);
 
 
-       if (conn->command_queue_count >
-           conn->server->set.max_pipelined_commands) {
+       if (!smtp_server_connection_check_pipeline(conn)) {
                smtp_server_connection_input_halt(conn);
                return;
        }