aboutsummaryrefslogtreecommitdiff
path: root/src/mail/ngx_mail_imap_handler.c
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2021-03-05 17:16:17 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2021-03-05 17:16:17 +0300
commit065a1641b242538073e92065e20fd788203108ab (patch)
tree40ed1a7599a54922d838f6700a61219834e04823 /src/mail/ngx_mail_imap_handler.c
parent8ed63c936c1493a25bdcb351a812de1ebac8b976 (diff)
downloadnginx-065a1641b242538073e92065e20fd788203108ab.tar.gz
nginx-065a1641b242538073e92065e20fd788203108ab.zip
Mail: added missing event handling after reading data.
If we need to be notified about further events, ngx_handle_read_event() needs to be called after a read event is processed. Without this, an event can be removed from the kernel and won't be reported again, notably when using oneshot event methods, such as eventport on Solaris. For consistency, existing ngx_handle_read_event() call removed from ngx_mail_read_command(), as this call only covers one of the code paths where ngx_mail_read_command() returns NGX_AGAIN. Instead, appropriate processing added to the callers, covering all code paths where NGX_AGAIN is returned.
Diffstat (limited to 'src/mail/ngx_mail_imap_handler.c')
-rw-r--r--src/mail/ngx_mail_imap_handler.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mail/ngx_mail_imap_handler.c b/src/mail/ngx_mail_imap_handler.c
index e31e4d0c8..5dfdd7601 100644
--- a/src/mail/ngx_mail_imap_handler.c
+++ b/src/mail/ngx_mail_imap_handler.c
@@ -136,7 +136,16 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
rc = ngx_mail_read_command(s, c);
- if (rc == NGX_AGAIN || rc == NGX_ERROR) {
+ if (rc == NGX_AGAIN) {
+ if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+ ngx_mail_session_internal_server_error(s);
+ return;
+ }
+
+ return;
+ }
+
+ if (rc == NGX_ERROR) {
return;
}
@@ -299,6 +308,11 @@ ngx_mail_imap_auth_state(ngx_event_t *rev)
}
}
+ if (ngx_handle_read_event(c->read, 0) != NGX_OK) {
+ ngx_mail_session_internal_server_error(s);
+ return;
+ }
+
ngx_mail_send(c->write);
}