]> git.kaiwu.me - nginx.git/commitdiff
SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0.
authorMaxim Dounin <mdounin@mdounin.ru>
Thu, 17 Oct 2019 13:02:13 +0000 (16:02 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Thu, 17 Oct 2019 13:02:13 +0000 (16:02 +0300)
As long as there are data to read in the socket, yet the amount of data
is less than total size of the buffers in the chain, this saves one
unneeded read() syscall.  Before this change, reading only stopped if
ngx_ssl_recv() returned no data, that is, two read() syscalls in a row
returned EAGAIN.

src/event/ngx_event_openssl.c

index 3737839d8e0a1e53eb6880725f6b05e4a021b4e4..4e3eb391c8b4d064ba4741e8df221b40520b7e45 100644 (file)
@@ -1922,6 +1922,10 @@ ngx_ssl_recv_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t limit)
             last += n;
             bytes += n;
 
+            if (!c->read->ready) {
+                return bytes;
+            }
+
             if (last == b->end) {
                 cl = cl->next;