Merging r4195, r4196:
AIO related fixes:
*) Fix for connection drops with AIO.
Connections serving content with AIO to fast clients were dropped with
"client timed out" messages after send_timeout from response start.
*) 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).
Igor Sysoev
10 years ago
2247 | 2247 |
return;
|
2248 | 2248 |
}
|
2249 | 2249 |
|
2250 | |
} else {
|
2251 | |
if (wev->delayed || r->aio) {
|
2252 | |
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0,
|
2253 | |
"http writer delayed");
|
2254 | |
|
2255 | |
if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
|
2256 | |
ngx_http_close_request(r, 0);
|
2257 | |
}
|
2258 | |
|
2259 | |
return;
|
2260 | |
}
|
|
2250 |
}
|
|
2251 |
|
|
2252 |
if (wev->delayed || r->aio) {
|
|
2253 |
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, wev->log, 0,
|
|
2254 |
"http writer delayed");
|
|
2255 |
|
|
2256 |
if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) {
|
|
2257 |
ngx_http_close_request(r, 0);
|
|
2258 |
}
|
|
2259 |
|
|
2260 |
return;
|
2261 | 2261 |
}
|
2262 | 2262 |
|
2263 | 2263 |
rc = ngx_http_output_filter(r, NULL);
|
|
2273 | 2273 |
|
2274 | 2274 |
if (r->buffered || r->postponed || (r == r->main && c->buffered)) {
|
2275 | 2275 |
|
2276 | |
if (!wev->ready && !wev->delayed) {
|
|
2276 |
if (!wev->delayed) {
|
2277 | 2277 |
ngx_add_timer(wev, clcf->send_timeout);
|
2278 | 2278 |
}
|
2279 | 2279 |
|