Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2018-09-10 18:57:13 +0300
committerMaxim Dounin <mdounin@mdounin.ru>2018-09-10 18:57:13 +0300
commit278be041ddbd91c28b496ca01213c47cbc96d958 (patch)
treec52f01192ece8bb4cfade42b01e0f2272935a4f0 /src/http
parent07dbfd00fff456d05007cc1f35bd5a5b1349ef08 (diff)
Lingering close changed to handle NGX_AGAIN.
The "do { c->recv() } while (c->read->ready)" form used in the ngx_http_lingering_close_handler() is not really correct, as for example with SSL c->read->ready may be still set when returning NGX_AGAIN due to SSL_ERROR_WANT_WRITE. Therefore the above might be an infinite loop. This doesn't really matter in lingering close, as we shutdown write side of the socket anyway and also disable renegotiation (and even without shutdown and with renegotiation it requires using very large certificate chain and tuning socket buffers to trigger SSL_ERROR_WANT_WRITE). But for the sake of correctness added an NGX_AGAIN check.
Diffstat (limited to 'src/http')
-rw-r--r--src/http/ngx_http_request.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index 979009158..d7e4d69f1 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -3311,6 +3311,10 @@ ngx_http_lingering_close_handler(ngx_event_t *rev)
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %z", n);
+ if (n == NGX_AGAIN) {
+ break;
+ }
+
if (n == NGX_ERROR || n == 0) {
ngx_http_close_request(r, 0);
return;