]> git.kaiwu.me - nginx.git/commitdiff
Event pipe: disabled c->read->available checking for SSL.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 17 Oct 2019 13:02:03 +0000 (16:02 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 17 Oct 2019 13:02:03 +0000 (16:02 +0300)
In SSL connections, data can be buffered by the SSL layer, and it is
wrong to avoid doing c->recv_chain() if c->read->available is 0 and
c->read->pending_eof is set.  And tests show that the optimization in
question indeed can result in incorrect detection of premature connection
close if upstream closes the connection without sending a close notify
alert at the same time.  Fix is to disable c->read->available optimization
for SSL connections.

src/event/ngx_event_pipe.c

index da7c4ee7fb755148a0d2a7672e3c820accf17c9e..531b13aade0349a2752521752f3cfa23ea4c97b7 100644 (file)
@@ -172,7 +172,11 @@ ngx_event_pipe_read_upstream(ngx_event_pipe_t *p)
              */
 
             if (p->upstream->read->available == 0
-                && p->upstream->read->pending_eof)
+                && p->upstream->read->pending_eof
+#if (NGX_SSL)
+                && !p->upstream->ssl
+#endif
+                )
             {
                 p->upstream->read->ready = 0;
                 p->upstream->read->eof = 1;