[nginx] Mail: added missing event handling after blocking events.

Maxim Dounin mdounin at mdounin.ru
Fri Mar 5 15:31:39 UTC 2021


details:   https://hg.nginx.org/nginx/rev/ab6257dac2a8
branches:  
changeset: 7789:ab6257dac2a8
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Fri Mar 05 17:16:16 2021 +0300
description:
Mail: added missing event handling after blocking events.

As long as a read event is blocked (ignored), ngx_handle_read_event()
needs to be called to make sure no further notifications will be
triggered when using level-triggered event methods, such as select() or
poll().

diffstat:

 src/mail/ngx_mail_imap_handler.c |  6 ++++++
 src/mail/ngx_mail_pop3_handler.c |  6 ++++++
 src/mail/ngx_mail_smtp_handler.c |  6 ++++++
 3 files changed, 18 insertions(+), 0 deletions(-)

diffs (48 lines):

diff -r 9ca8fb98ef1c -r ab6257dac2a8 src/mail/ngx_mail_imap_handler.c
--- a/src/mail/ngx_mail_imap_handler.c	Fri Mar 05 17:16:15 2021 +0300
+++ b/src/mail/ngx_mail_imap_handler.c	Fri Mar 05 17:16:16 2021 +0300
@@ -123,6 +123,12 @@ ngx_mail_imap_auth_state(ngx_event_t *re
     if (s->out.len) {
         ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "imap send handler busy");
         s->blocked = 1;
+
+        if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+            ngx_mail_close_connection(c);
+            return;
+        }
+
         return;
     }
 
diff -r 9ca8fb98ef1c -r ab6257dac2a8 src/mail/ngx_mail_pop3_handler.c
--- a/src/mail/ngx_mail_pop3_handler.c	Fri Mar 05 17:16:15 2021 +0300
+++ b/src/mail/ngx_mail_pop3_handler.c	Fri Mar 05 17:16:16 2021 +0300
@@ -138,6 +138,12 @@ ngx_mail_pop3_auth_state(ngx_event_t *re
     if (s->out.len) {
         ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "pop3 send handler busy");
         s->blocked = 1;
+
+        if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+            ngx_mail_close_connection(c);
+            return;
+        }
+
         return;
     }
 
diff -r 9ca8fb98ef1c -r ab6257dac2a8 src/mail/ngx_mail_smtp_handler.c
--- a/src/mail/ngx_mail_smtp_handler.c	Fri Mar 05 17:16:15 2021 +0300
+++ b/src/mail/ngx_mail_smtp_handler.c	Fri Mar 05 17:16:16 2021 +0300
@@ -449,6 +449,12 @@ ngx_mail_smtp_auth_state(ngx_event_t *re
     if (s->out.len) {
         ngx_log_debug0(NGX_LOG_DEBUG_MAIL, c->log, 0, "smtp send handler busy");
         s->blocked = 1;
+
+        if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+            ngx_mail_close_connection(c);
+            return;
+        }
+
         return;
     }
 


More information about the nginx-devel mailing list