]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-server-command - Add smtp_server_command_pipeline_block/unblock().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Sun, 8 Nov 2020 02:58:06 +0000 (03:58 +0100)
committerMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Fri, 21 Jan 2022 07:37:36 +0000 (09:37 +0200)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-connection.c
src/lib-smtp/smtp-server-private.h
src/lib-smtp/smtp-server.h

index f8a1dbc84f876187d793bdfc71afd197208eb3e3..992a3457516d38ddcaacb452edb1d05832ffa34b 100644 (file)
@@ -324,6 +324,8 @@ bool smtp_server_command_unref(struct smtp_server_command **_cmd)
                &cmd, SMTP_SERVER_COMMAND_HOOK_DESTROY, TRUE))
                i_unreached();
 
+       smtp_server_command_pipeline_unblock(&cmd->context);
+
        smtp_server_reply_free(cmd);
        event_unref(&cmd->context.event);
        pool_unref(&cmd->context.pool);
@@ -355,6 +357,7 @@ void smtp_server_command_abort(struct smtp_server_command **_cmd)
        }
        smtp_server_reply_free(cmd);
 
+       smtp_server_command_pipeline_unblock(&cmd->context);
        smtp_server_command_unref(_cmd);
 }
 
@@ -528,6 +531,9 @@ bool smtp_server_command_completed(struct smtp_server_command **_cmd)
 
        e_debug(cmd->context.event, "Completed");
 
+       if (cmd->pipeline_blocked)
+               smtp_server_command_pipeline_unblock(&cmd->context);
+
        return smtp_server_command_call_hooks(
                _cmd, SMTP_SERVER_COMMAND_HOOK_COMPLETED, TRUE);
 }
@@ -791,9 +797,11 @@ void smtp_server_command_finished(struct smtp_server_command *cmd)
                }
                smtp_server_command_unref(&cmd);
                return;
-       } else if (cmd->input_locked) {
-               smtp_server_command_input_unlock(&cmd->context);
        }
+       if (cmd->input_locked)
+               smtp_server_command_input_unlock(&cmd->context);
+       if (cmd->pipeline_blocked)
+               smtp_server_command_pipeline_unblock(&cmd->context);
 
        smtp_server_command_unref(&cmd);
        smtp_server_connection_trigger_output(conn);
@@ -866,3 +874,28 @@ void smtp_server_command_input_capture(
        command->input_locked = TRUE;
        command->input_captured = TRUE;
 }
+
+void smtp_server_command_pipeline_block(struct smtp_server_cmd_ctx *cmd)
+{
+       struct smtp_server_command *command = cmd->cmd;
+       struct smtp_server_connection *conn = cmd->conn;
+
+       e_debug(cmd->event, "Pipeline blocked");
+
+       command->pipeline_blocked = TRUE;
+       smtp_server_connection_input_lock(conn);
+}
+
+void smtp_server_command_pipeline_unblock(struct smtp_server_cmd_ctx *cmd)
+{
+       struct smtp_server_command *command = cmd->cmd;
+       struct smtp_server_connection *conn = cmd->conn;
+
+       if (!command->pipeline_blocked)
+               return;
+
+       command->pipeline_blocked = FALSE;
+       smtp_server_connection_input_unlock(conn);
+
+       e_debug(cmd->event, "Pipeline unblocked");
+}
index 092cc0c33253d85d52d8f4bd5cfa1f0c0f7ba26c..f301e82ba489589670d3ff98ef011e602a12362d 100644 (file)
@@ -101,7 +101,7 @@ void smtp_server_connection_input_resume(struct smtp_server_connection *conn)
                /* Is queued command still blocking input? */
                cmd = conn->command_queue_head;
                while (cmd != NULL) {
-                       if (cmd->input_locked) {
+                       if (cmd->input_locked || cmd->pipeline_blocked) {
                                cmd_locked = TRUE;
                                break;
                        }
index 136256a092c9d74f1de06863106f8cc0bbbb1bb2..7a923365b4252f57e866a96726a45803e9468677 100644 (file)
@@ -108,6 +108,7 @@ struct smtp_server_command {
 
        bool input_locked:1;
        bool input_captured:1;
+       bool pipeline_blocked:1;
        bool reply_early:1;
        bool destroying:1;
 };
index a31a535bba363c293ad61862a5b9a953fb5a3868..5c13491380f090d47a365d32ec72dc3c2d92f46e 100644 (file)
@@ -628,6 +628,9 @@ void smtp_server_command_input_capture(
        struct smtp_server_cmd_ctx *cmd,
        smtp_server_cmd_input_callback_t *callback);
 
+void smtp_server_command_pipeline_block(struct smtp_server_cmd_ctx *cmd);
+void smtp_server_command_pipeline_unblock(struct smtp_server_cmd_ctx *cmd);
+
 /* EHLO */
 
 void smtp_server_cmd_ehlo(struct smtp_server_cmd_ctx *cmd, const char *params);