comparison src/mail/ngx_mail_proxy_module.c @ 8151:a5e6e8510634

Mail: fixed handling of blocked client read events in proxy. When establishing a connection to the backend, nginx blocks reading from the client with ngx_mail_proxy_block_read(). Previously, such events were lost, and in some cases this resulted in connection hangs. Notably, this affected mail_imap_ssl.t on Windows, since the test closes connections after requesting authentication, but without waiting for any responses (so the connection close events might be lost). Fix is to post an event to read from the client after connecting to the backend if there were blocked events.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 24 Mar 2023 02:53:21 +0300
parents 17d6a537fb1b
children
comparison
equal deleted inserted replaced
8150:8771d35d55d0 8151:a5e6e8510634
325 ngx_del_timer(c->read); 325 ngx_del_timer(c->read);
326 326
327 c->log->action = NULL; 327 c->log->action = NULL;
328 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in"); 328 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in");
329 329
330 if (s->buffer->pos < s->buffer->last) { 330 if (s->buffer->pos < s->buffer->last
331 || s->connection->read->ready)
332 {
331 ngx_post_event(c->write, &ngx_posted_events); 333 ngx_post_event(c->write, &ngx_posted_events);
332 } 334 }
333 335
334 ngx_mail_proxy_handler(s->connection->write); 336 ngx_mail_proxy_handler(s->connection->write);
335 337
484 ngx_del_timer(c->read); 486 ngx_del_timer(c->read);
485 487
486 c->log->action = NULL; 488 c->log->action = NULL;
487 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in"); 489 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in");
488 490
489 if (s->buffer->pos < s->buffer->last) { 491 if (s->buffer->pos < s->buffer->last
492 || s->connection->read->ready)
493 {
490 ngx_post_event(c->write, &ngx_posted_events); 494 ngx_post_event(c->write, &ngx_posted_events);
491 } 495 }
492 496
493 ngx_mail_proxy_handler(s->connection->write); 497 ngx_mail_proxy_handler(s->connection->write);
494 498
819 ngx_del_timer(c->read); 823 ngx_del_timer(c->read);
820 824
821 c->log->action = NULL; 825 c->log->action = NULL;
822 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in"); 826 ngx_log_error(NGX_LOG_INFO, c->log, 0, "client logged in");
823 827
824 if (s->buffer->pos < s->buffer->last) { 828 if (s->buffer->pos < s->buffer->last
829 || s->connection->read->ready)
830 {
825 ngx_post_event(c->write, &ngx_posted_events); 831 ngx_post_event(c->write, &ngx_posted_events);
826 } 832 }
827 833
828 ngx_mail_proxy_handler(s->connection->write); 834 ngx_mail_proxy_handler(s->connection->write);
829 835