]> git.kaiwu.me - nginx.git/commitdiff
SSL: fixed c->read->ready handling in ngx_ssl_recv().
authorMaxim Dounin <mdounin@mdounin.ru>
Fri, 29 Nov 2013 13:16:06 +0000 (17:16 +0400)
committerMaxim Dounin <mdounin@mdounin.ru>
Fri, 29 Nov 2013 13:16:06 +0000 (17:16 +0400)
If c->read->ready was reset, but later some data were read from a socket
buffer due to a call to ngx_ssl_recv(), the c->read->ready flag should
be restored if not all data were read from OpenSSL buffers (as kernel
won't notify us about the data anymore).

More details are available here:
http://mailman.nginx.org/pipermail/nginx/2013-November/041178.html

src/event/ngx_event_openssl.c

index e4bc1a2c774eb3e4d4815f20d7b94fef664f8c25..ee66713504d621e65a5db1c669eee5261bcc28bf 100644 (file)
@@ -1025,6 +1025,7 @@ ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
             size -= n;
 
             if (size == 0) {
+                c->read->ready = 1;
                 return bytes;
             }
 
@@ -1034,6 +1035,10 @@ ngx_ssl_recv(ngx_connection_t *c, u_char *buf, size_t size)
         }
 
         if (bytes) {
+            if (c->ssl->last != NGX_AGAIN) {
+                c->read->ready = 1;
+            }
+
             return bytes;
         }