]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: smtp-server-command - Split off smtp_server_command_send_replies().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 5 Nov 2021 15:46:15 +0000 (16:46 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Wed, 10 Nov 2021 08:44:08 +0000 (08:44 +0000)
src/lib-smtp/smtp-server-command.c
src/lib-smtp/smtp-server-connection.c
src/lib-smtp/smtp-server-private.h

index ed4b0258bed076903cfbddfafad1f60246c9e282..a7bf47dd353b9fe028da0bca8afa5af11d418834 100644 (file)
@@ -692,6 +692,44 @@ bool smtp_server_command_replied_success(struct smtp_server_command *cmd)
        return success;
 }
 
+bool smtp_server_command_send_replies(struct smtp_server_command *cmd)
+{
+       unsigned int i;
+
+       if (!smtp_server_command_next_to_reply(&cmd))
+               return FALSE;
+       if (cmd->state < SMTP_SERVER_COMMAND_STATE_READY_TO_REPLY)
+               return FALSE;
+
+       i_assert(cmd->state == SMTP_SERVER_COMMAND_STATE_READY_TO_REPLY &&
+                array_is_created(&cmd->replies));
+
+       if (!smtp_server_command_completed(&cmd))
+               return TRUE;
+
+       /* Send command replies */
+       // FIXME: handle LMTP DATA command with enormous number of recipients;
+       // i.e. don't keep filling output stream with replies indefinitely.
+       for (i = 0; i < cmd->replies_expected; i++) {
+               struct smtp_server_reply *reply;
+
+               reply = array_idx_modifiable(&cmd->replies, i);
+
+               if (!reply->submitted) {
+                       i_assert(!reply->sent);
+                       cmd->state = SMTP_SERVER_COMMAND_STATE_PROCESSING;
+                       break;
+               }
+               if (smtp_server_reply_send(reply) < 0)
+                       return FALSE;
+       }
+       if (cmd->state == SMTP_SERVER_COMMAND_STATE_PROCESSING)
+               return FALSE;
+
+       smtp_server_command_finished(cmd);
+       return TRUE;
+}
+
 void smtp_server_command_finished(struct smtp_server_command *cmd)
 {
        struct smtp_server_connection *conn = cmd->context.conn;
index 43abb24f74940fab9d064ca99c5f57f5316ec1e0..092cc0c33253d85d52d8f4bd5cfa1f0c0f7ba26c 100644 (file)
@@ -626,7 +626,6 @@ static bool
 smtp_server_connection_next_reply(struct smtp_server_connection *conn)
 {
        struct smtp_server_command *cmd;
-       unsigned int i;
 
        cmd = conn->command_queue_head;
        if (cmd == NULL) {
@@ -635,38 +634,7 @@ smtp_server_connection_next_reply(struct smtp_server_connection *conn)
                return FALSE;
        }
 
-       if (!smtp_server_command_next_to_reply(&cmd))
-               return FALSE;
-       if (cmd->state < SMTP_SERVER_COMMAND_STATE_READY_TO_REPLY)
-               return FALSE;
-
-       i_assert(cmd->state == SMTP_SERVER_COMMAND_STATE_READY_TO_REPLY &&
-                array_is_created(&cmd->replies));
-
-       if (!smtp_server_command_completed(&cmd))
-               return TRUE;
-
-       /* Send command replies */
-       // FIXME: handle LMTP DATA command with enormous number of recipients;
-       // i.e. don't keep filling output stream with replies indefinitely.
-       for (i = 0; i < cmd->replies_expected; i++) {
-               struct smtp_server_reply *reply;
-
-               reply = array_idx_modifiable(&cmd->replies, i);
-
-               if (!reply->submitted) {
-                       i_assert(!reply->sent);
-                       cmd->state = SMTP_SERVER_COMMAND_STATE_PROCESSING;
-                       break;
-               }
-               if (smtp_server_reply_send(reply) < 0)
-                       return FALSE;
-       }
-       if (cmd->state == SMTP_SERVER_COMMAND_STATE_PROCESSING)
-               return FALSE;
-
-       smtp_server_command_finished(cmd);
-       return TRUE;
+       return smtp_server_command_send_replies(cmd);
 }
 
 void smtp_server_connection_cork(struct smtp_server_connection *conn)
index e4fe4f4adad845872ae6d18d3e3184e3208a9cf5..136256a092c9d74f1de06863106f8cc0bbbb1bb2 100644 (file)
@@ -264,6 +264,7 @@ void smtp_server_command_submit_reply(struct smtp_server_command *cmd);
 int smtp_server_connection_flush(struct smtp_server_connection *conn);
 
 void smtp_server_command_ready_to_reply(struct smtp_server_command *cmd);
+bool smtp_server_command_send_replies(struct smtp_server_command *cmd);
 void smtp_server_command_finished(struct smtp_server_command *cmd);
 
 bool smtp_server_command_next_to_reply(struct smtp_server_command **_cmd);