Welcome! Log In Create A New Profile


[nginx] Mail: fixed SMTP pipelining to send the response immediately.

Maxim Dounin
May 18, 2021 09:28PM
details: https://hg.nginx.org/nginx/rev/c72d8839f427
changeset: 7835:c72d8839f427
user: Maxim Dounin <mdounin@mdounin.ru>
date: Wed May 19 03:13:12 2021 +0300
Mail: fixed SMTP pipelining to send the response immediately.

Previously, if there were some pipelined SMTP data in the buffer when
a proxied connection with the backend was established, nginx called
ngx_mail_proxy_handler() to send these data, and not tried to send the
response to the last command. In most cases, this response was later sent
along with the response to the pipelined command, but if for some reason
client decides to wait for the response before finishing the next command
this might result in a connection hang.

Fix is to always call ngx_mail_proxy_handler() to send the response, and
additionally post an event to send the pipelined data if needed.


src/mail/ngx_mail_proxy_module.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diffs (20 lines):

diff -r b3f4d83d6fd0 -r c72d8839f427 src/mail/ngx_mail_proxy_module.c
--- a/src/mail/ngx_mail_proxy_module.c Sat May 08 20:31:03 2021 +0300
+++ b/src/mail/ngx_mail_proxy_module.c Wed May 19 03:13:12 2021 +0300
@@ -813,12 +813,11 @@ ngx_mail_proxy_smtp_handler(ngx_event_t
c->log->action = NULL;
ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in");

- if (s->buffer->pos == s->buffer->last) {
- ngx_mail_proxy_handler(s->connection->write);
+ if (s->buffer->pos < s->buffer->last) {
+ ngx_post_event(c->write, &ngx_posted_events);
+ }

- } else {
- ngx_mail_proxy_handler(c->write);
- }
+ ngx_mail_proxy_handler(s->connection->write);


nginx-devel mailing list
Subject Author Views Posted

[nginx] Mail: fixed SMTP pipelining to send the response immediately.

Maxim Dounin 206 May 18, 2021 09:28PM

Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 66
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready