[nginx] SSL: improved ngx_ssl_recv_chain() to stop if c->read->ready is 0.

Maxim Dounin mdounin at mdounin.ru
Thu Oct 17 13:08:00 UTC 2019


details:   https://hg.nginx.org/nginx/rev/70749256af79
branches:  
changeset: 7582:70749256af79
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Oct 17 16:02:13 2019 +0300
description:
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.

diffstat:

 src/event/ngx_event_openssl.c |  4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diffs (14 lines):

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;
 


More information about the nginx-devel mailing list