Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 7351:2b5528023f6b
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.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 10 Sep 2018 18:57:13 +0300 |
parents | 3443fe40bdc7 |
children | 1812f1d79d84 |
comparison
equal
deleted
inserted
replaced
7350:67c6cb7f477c | 7351:2b5528023f6b |
---|---|
3309 do { | 3309 do { |
3310 n = c->recv(c, buffer, NGX_HTTP_LINGERING_BUFFER_SIZE); | 3310 n = c->recv(c, buffer, NGX_HTTP_LINGERING_BUFFER_SIZE); |
3311 | 3311 |
3312 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %z", n); | 3312 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "lingering read: %z", n); |
3313 | 3313 |
3314 if (n == NGX_AGAIN) { | |
3315 break; | |
3316 } | |
3317 | |
3314 if (n == NGX_ERROR || n == 0) { | 3318 if (n == NGX_ERROR || n == 0) { |
3315 ngx_http_close_request(r, 0); | 3319 ngx_http_close_request(r, 0); |
3316 return; | 3320 return; |
3317 } | 3321 } |
3318 | 3322 |