From: Stephan Bosch Date: Sun, 8 Nov 2020 02:58:06 +0000 (+0100) Subject: lib-smtp: smtp-server-command - Add smtp_server_command_pipeline_block/unblock(). X-Git-Tag: 2.3.19~132 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5aeca06ad618d4af162232265ac85046e9a47de5;p=thirdparty%2Fdovecot%2Fcore.git lib-smtp: smtp-server-command - Add smtp_server_command_pipeline_block/unblock(). --- diff --git a/src/lib-smtp/smtp-server-command.c b/src/lib-smtp/smtp-server-command.c index f8a1dbc84f..992a345751 100644 --- a/src/lib-smtp/smtp-server-command.c +++ b/src/lib-smtp/smtp-server-command.c @@ -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"); +} diff --git a/src/lib-smtp/smtp-server-connection.c b/src/lib-smtp/smtp-server-connection.c index 092cc0c332..f301e82ba4 100644 --- a/src/lib-smtp/smtp-server-connection.c +++ b/src/lib-smtp/smtp-server-connection.c @@ -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; } diff --git a/src/lib-smtp/smtp-server-private.h b/src/lib-smtp/smtp-server-private.h index 136256a092..7a923365b4 100644 --- a/src/lib-smtp/smtp-server-private.h +++ b/src/lib-smtp/smtp-server-private.h @@ -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; }; diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index a31a535bba..5c13491380 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -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);