# HG changeset patch # User Maxim Dounin # Date 1571317333 -10800 # Node ID 70749256af794d615d07e2350a301bd5814e4b86 # Parent afceb32f3a8a231833f34b04032c6123e97bddf4 SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0. 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. diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c --- a/src/event/ngx_event_openssl.c +++ b/src/event/ngx_event_openssl.c @@ -1922,6 +1922,10 @@ ngx_ssl_recv_chain(ngx_connection_t *c, last += n; bytes += n; + if (!c->read->ready) { + return bytes; + } + if (last == b->end) { cl = cl->next;