diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-10-11 18:00:23 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-10-11 18:00:23 +0000 |
commit | 0f5f4cb1805e70c8fab3bcd13e18ad24670b47ba (patch) | |
tree | dc6f50cbf63af9a9fe92317497f83910f1aeef1d /src/http/ngx_http_request.c | |
parent | b7af402cc40136db0a7b03af6a380eb405cb0910 (diff) | |
download | nginx-0f5f4cb1805e70c8fab3bcd13e18ad24670b47ba.tar.gz nginx-0f5f4cb1805e70c8fab3bcd13e18ad24670b47ba.zip |
Fix for socket leak with "aio sendfile" and "limit_rate".
Second aio post happened when timer set by limit_rate expired while we have
aio request in flight, resulting in "second aio post" alert and socket leak.
The patch adds actual protection from aio calls with r->aio already set to
aio sendfile code in ngx_http_copy_filter(). This should fix other cases
as well, e.g. when sending buffered to disk upstream replies while still
talking to upstream.
The ngx_http_writer() is also fixed to handle the above case (though it's
mostly optimization now).
Reported by Oleksandr V. Typlyns'kyi.
Diffstat (limited to 'src/http/ngx_http_request.c')
-rw-r--r-- | src/http/ngx_http_request.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index c1f806ab6..c0d56ecaa 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -2248,17 +2248,17 @@ ngx_http_writer(ngx_http_request_t *r) return; } - } else { - if (wev->delayed || r->aio) { - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, - "http writer delayed"); + } - if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { - ngx_http_close_request(r, 0); - } + if (wev->delayed || r->aio) { + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, + "http writer delayed"); - return; + if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { + ngx_http_close_request(r, 0); } + + return; } rc = ngx_http_output_filter(r, NULL); |