Klaus Demo nginx / a1db86a
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
2 changed file(s) with 17 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
157157 ngx_file_t *file;
158158 ngx_http_ephemeral_t *e;
159159
160 if (r->aio) {
161 c->busy_sendfile = NULL;
162 return rc;
163 }
164
160165 file = c->busy_sendfile->file;
161166 offset = c->busy_sendfile->file_pos;
162167
22472247 return;
22482248 }
22492249
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;
22612261 }
22622262
22632263 rc = ngx_http_output_filter(r, NULL);
22732273
22742274 if (r->buffered || r->postponed || (r == r->main && c->buffered)) {
22752275
2276 if (!wev->ready && !wev->delayed) {
2276 if (!wev->delayed) {
22772277 ngx_add_timer(wev, clcf->send_timeout);
22782278 }
22792279