Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 7631:b4dbf8b98f9a
Fixed premature background subrequest finalization.
When "aio" or "aio threads" is used while processing the response body of an
in-memory background subrequest, the subrequest could be finalized with an aio
operation still in progress. Upon aio completion either parent request is
woken or the old r->write_event_handler is called again. The latter may result
in request errors. In either case post_subrequest handler is never called with
the full response body, which is typically expected when using in-memory
subrequests.
Currently in nginx background subrequests are created by the upstream module
and the mirror module. The issue does not manifest itself with these
subrequests because they are header-only. But it can manifest itself with
third-party modules which create in-memory background subrequests.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Mon, 02 Mar 2020 20:07:36 +0300 |
parents | 2e3bfd696ecb |
children | 1d207b77b44a |
comparison
equal
deleted
inserted
replaced
7630:f001d9384293 | 7631:b4dbf8b98f9a |
---|---|
2488 } | 2488 } |
2489 | 2489 |
2490 if (r != r->main) { | 2490 if (r != r->main) { |
2491 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 2491 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
2492 | 2492 |
2493 if (r->buffered || r->postponed) { | |
2494 | |
2495 if (ngx_http_set_write_handler(r) != NGX_OK) { | |
2496 ngx_http_terminate_request(r, 0); | |
2497 } | |
2498 | |
2499 return; | |
2500 } | |
2501 | |
2493 if (r->background) { | 2502 if (r->background) { |
2494 if (!r->logged) { | 2503 if (!r->logged) { |
2495 if (clcf->log_subrequest) { | 2504 if (clcf->log_subrequest) { |
2496 ngx_http_log_request(r); | 2505 ngx_http_log_request(r); |
2497 } | 2506 } |
2504 &r->uri, &r->args); | 2513 &r->uri, &r->args); |
2505 } | 2514 } |
2506 | 2515 |
2507 r->done = 1; | 2516 r->done = 1; |
2508 ngx_http_finalize_connection(r); | 2517 ngx_http_finalize_connection(r); |
2509 return; | |
2510 } | |
2511 | |
2512 if (r->buffered || r->postponed) { | |
2513 | |
2514 if (ngx_http_set_write_handler(r) != NGX_OK) { | |
2515 ngx_http_terminate_request(r, 0); | |
2516 } | |
2517 | |
2518 return; | 2518 return; |
2519 } | 2519 } |
2520 | 2520 |
2521 pr = r->parent; | 2521 pr = r->parent; |
2522 | 2522 |