diff src/event/ngx_event_openssl.c @ 7612:1ce3f01a4355

SSL: reworked posted next events. Introduced in 9d2ad2fb4423 available bytes handling in SSL relied on connection read handler being overwritten to set the ready flag and the amount of available bytes. This approach is, however, does not work properly when connection read handler is changed, for example, when switching to a next pipelined request, and can result in unexpected connection timeouts, see here: http://mailman.nginx.org/pipermail/nginx-devel/2019-December/012825.html Fix is to introduce ngx_event_process_posted_next() instead, which will set ready and available regardless of how event handler is set.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 24 Dec 2019 17:24:59 +0300
parents 9d2ad2fb4423
children f1720934c45b
line wrap: on
line diff
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -43,7 +43,6 @@ static ssize_t ngx_ssl_recv_early(ngx_co
 #endif
 static ngx_int_t ngx_ssl_handle_recv(ngx_connection_t *c, int n);
 static void ngx_ssl_write_handler(ngx_event_t *wev);
-static void ngx_ssl_next_read_handler(ngx_event_t *rev);
 #ifdef SSL_READ_EARLY_DATA_SUCCESS
 static ssize_t ngx_ssl_write_early(ngx_connection_t *c, u_char *data,
     size_t size);
@@ -2018,11 +2017,6 @@ ngx_ssl_recv(ngx_connection_t *c, u_char
                         c->read->available = 0;
                         c->read->ready = 0;
 
-                        if (c->ssl->next_read_handler == NULL) {
-                            c->ssl->next_read_handler = c->read->handler;
-                            c->read->handler = ngx_ssl_next_read_handler;
-                        }
-
                         ngx_post_event(c->read, &ngx_posted_next_events);
                     }
 
@@ -2328,31 +2322,6 @@ ngx_ssl_write_handler(ngx_event_t *wev)
 }
 
 
-static void
-ngx_ssl_next_read_handler(ngx_event_t *rev)
-{
-    ngx_connection_t  *c;
-
-    c = rev->data;
-
-    ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "SSL next read handler");
-
-    rev->handler = c->ssl->next_read_handler;
-    c->ssl->next_read_handler = NULL;
-
-    if (!rev->ready) {
-        rev->ready = 1;
-        rev->available = -1;
-    }
-
-    if (rev->posted) {
-        ngx_delete_posted_event(rev);
-    }
-
-    rev->handler(rev);
-}
-
-
 /*
  * OpenSSL has no SSL_writev() so we copy several bufs into our 16K buffer
  * before the SSL_write() call to decrease a SSL overhead.