aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2021-05-19 03:13:12 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2021-05-19 03:13:12 +0300
commit60a5a6f0d37b2e10d8d4aab97b64f4048e99c99a (patch)
tree96c445da24f0bd21cd65e2b7e398f780efa89884 /src
parent130a3ec5010227ca93498a1eb3a182062daeb349 (diff)
downloadnginx-60a5a6f0d37b2e10d8d4aab97b64f4048e99c99a.tar.gz
nginx-60a5a6f0d37b2e10d8d4aab97b64f4048e99c99a.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/mail/ngx_mail_proxy_module.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/mail/ngx_mail_proxy_module.c b/src/mail/ngx_mail_proxy_module.c
index 66aa0ba09..38164af95 100644
--- a/src/mail/ngx_mail_proxy_module.c
+++ b/src/mail/ngx_mail_proxy_module.c
@@ -813,13 +813,12 @@ ngx_mail_proxy_smtp_handler(ngx_event_t *rev)
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);
-
- } else {
- ngx_mail_proxy_handler(c->write);
+ if (s->buffer->pos < s->buffer->last) {
+ ngx_post_event(c->write, &ngx_posted_events);
}
+ ngx_mail_proxy_handler(s->connection->write);
+
return;
default: