Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 7011:5e05118678af
Fixed background requests with asynchronous operations.
If the main request was finalized while a background request performed an
asynchronous operation, the main request ended up in ngx_http_writer() and was
not finalized until a network event or a timeout. For example, cache
background update with aio enabled made nginx unable to process further client
requests or close the connection, keeping it open until client closes it.
Now regular finalization of the main request is not suspended because of an
asynchronous operation in another request.
If a background request was terminated while an asynchronous operation was in
progress, background request's write event handler was changed to
ngx_http_request_finalizer() and never called again.
Now, whenever a request is terminated while an asynchronous operation is in
progress, connection error flag is set to make further finalizations of any
request with this connection lead to termination.
These issues appeared in 1aeaae6e9446 (not yet released).
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Mon, 29 May 2017 23:33:38 +0300 |
parents | 29c6d66b83ba |
children | 1b068a4e82d8 |
comparison
equal
deleted
inserted
replaced
7010:c1524829af3d | 7011:5e05118678af |
---|---|
2329 { | 2329 { |
2330 if (ngx_http_post_action(r) == NGX_OK) { | 2330 if (ngx_http_post_action(r) == NGX_OK) { |
2331 return; | 2331 return; |
2332 } | 2332 } |
2333 | 2333 |
2334 if (r->main->blocked) { | |
2335 r->write_event_handler = ngx_http_request_finalizer; | |
2336 } | |
2337 | |
2338 ngx_http_terminate_request(r, rc); | 2334 ngx_http_terminate_request(r, rc); |
2339 return; | 2335 return; |
2340 } | 2336 } |
2341 | 2337 |
2342 if (rc >= NGX_HTTP_SPECIAL_RESPONSE | 2338 if (rc >= NGX_HTTP_SPECIAL_RESPONSE |
2447 &pr->uri, &pr->args); | 2443 &pr->uri, &pr->args); |
2448 | 2444 |
2449 return; | 2445 return; |
2450 } | 2446 } |
2451 | 2447 |
2452 if (r->buffered || c->buffered || r->postponed || r->blocked) { | 2448 if (r->buffered || c->buffered || r->postponed) { |
2453 | 2449 |
2454 if (ngx_http_set_write_handler(r) != NGX_OK) { | 2450 if (ngx_http_set_write_handler(r) != NGX_OK) { |
2455 ngx_http_terminate_request(r, 0); | 2451 ngx_http_terminate_request(r, 0); |
2456 } | 2452 } |
2457 | 2453 |
2528 mr->count, mr->blocked); | 2524 mr->count, mr->blocked); |
2529 | 2525 |
2530 if (mr->write_event_handler) { | 2526 if (mr->write_event_handler) { |
2531 | 2527 |
2532 if (mr->blocked) { | 2528 if (mr->blocked) { |
2529 r->connection->error = 1; | |
2530 r->write_event_handler = ngx_http_request_finalizer; | |
2533 return; | 2531 return; |
2534 } | 2532 } |
2535 | 2533 |
2536 e = ngx_http_ephemeral(mr); | 2534 e = ngx_http_ephemeral(mr); |
2537 mr->posted_requests = NULL; | 2535 mr->posted_requests = NULL; |