comparison src/http/ngx_http_request.c @ 4195:35f4997c08ce

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 11 Oct 2011 18:00:23 +0000
parents 7ce8f2cde0af
children ed922fb9d6c1
comparison
equal deleted inserted replaced
4194:7ce8f2cde0af 4195:35f4997c08ce
2246 } 2246 }
2247 2247
2248 return; 2248 return;
2249 } 2249 }
2250 2250
2251 } else { 2251 }
2252 if (wev->delayed || r->aio) { 2252
2253 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0, 2253 if (wev->delayed || r->aio) {
2254 "http writer delayed"); 2254 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0,
2255 2255 "http writer delayed");
2256 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { 2256
2257 ngx_http_close_request(r, 0); 2257 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
2258 } 2258 ngx_http_close_request(r, 0);
2259 2259 }
2260 return; 2260
2261 } 2261 return;
2262 } 2262 }
2263 2263
2264 rc = ngx_http_output_filter(r, NULL); 2264 rc = ngx_http_output_filter(r, NULL);
2265 2265
2266 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, 2266 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0,