From: Timo Sirainen Date: Thu, 7 May 2026 10:57:59 +0000 (+0000) Subject: [PATCH 3/5] lib-smtp: smtp-server - Expose smtp_server_connection_reply_immediate X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~23 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2a33a46473ef25f012cd19d84d8e25014a6b4e86;p=dovecot.git [PATCH 3/5] lib-smtp: smtp-server - Expose smtp_server_connection_reply_immediate The function already existed internally as a way to write a reply directly to the output stream, bypassing the per-command reply queue. Make it part of the public API so callers that need a reply on the wire before tearing the connection down (where queued replies would otherwise be aborted) can use it. Gbp-Pq: Name 0003-lib-smtp-smtp-server-Expose-smtp_server_connection_r.patch --- diff --git a/src/lib-smtp/smtp-server-private.h b/src/lib-smtp/smtp-server-private.h index e8cae54..b3812fe 100644 --- a/src/lib-smtp/smtp-server-private.h +++ b/src/lib-smtp/smtp-server-private.h @@ -323,9 +323,6 @@ void smtp_server_connection_reply_lines(struct smtp_server_connection *conn, unsigned int status, const char *enh_code, const char *const *text_lines); -void smtp_server_connection_reply_immediate( - struct smtp_server_connection *conn, unsigned int status, - const char *fmt, ...) ATTR_FORMAT(3, 4); void smtp_server_connection_reset_state(struct smtp_server_connection *conn); void smtp_server_connection_set_state(struct smtp_server_connection *conn, diff --git a/src/lib-smtp/smtp-server.h b/src/lib-smtp/smtp-server.h index 9f5bff5..be0c3d0 100644 --- a/src/lib-smtp/smtp-server.h +++ b/src/lib-smtp/smtp-server.h @@ -477,6 +477,16 @@ void smtp_server_connection_set_ssl_streams(struct smtp_server_connection *conn, void smtp_server_connection_close(struct smtp_server_connection **_conn, const char *reason) ATTR_NULL(2); bool smtp_server_connection_is_closed(struct smtp_server_connection *conn); +/* Send a reply line directly to the output stream, bypassing the per-command + reply queue. Useful when the caller is about to close the connection and + needs the reply on the wire before close/destroy aborts queued replies. + The formatted text must be a single line (no CR/LF); unlike + smtp_server_reply_add_text(), this function does not split on \n nor add + the SMTP continuation prefix to subsequent lines. */ +void smtp_server_connection_reply_immediate(struct smtp_server_connection *conn, + unsigned int status, + const char *fmt, ...) + ATTR_FORMAT(3, 4); void smtp_server_connection_terminate(struct smtp_server_connection **_conn, const char *enh_code, const char *reason) ATTR_NULL(3);