Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 4254:35861ba428d1 stable-1.0
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).
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 01 Nov 2011 14:13:25 +0000 |
parents | 8d39230df833 |
children | 096c859b2113 |
comparison
equal
deleted
inserted
replaced
4253:6efec8b1ff52 | 4254:35861ba428d1 |
---|---|
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, |
2272 return; | 2272 return; |
2273 } | 2273 } |
2274 | 2274 |
2275 if (r->buffered || r->postponed || (r == r->main && c->buffered)) { | 2275 if (r->buffered || r->postponed || (r == r->main && c->buffered)) { |
2276 | 2276 |
2277 if (!wev->ready && !wev->delayed) { | 2277 if (!wev->delayed) { |
2278 ngx_add_timer(wev, clcf->send_timeout); | 2278 ngx_add_timer(wev, clcf->send_timeout); |
2279 } | 2279 } |
2280 | 2280 |
2281 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { | 2281 if (ngx_handle_write_event(wev, clcf->send_lowat) != NGX_OK) { |
2282 ngx_http_close_request(r, 0); | 2282 ngx_http_close_request(r, 0); |