mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Fixed request counting with subrequests in case of error.
Previously, when creating a subrequest, request count increment could be missed in case of error after it became active. This resulted in "http request count is zero" alerts and socket leaks. Further, if posting the next subrequest resulted in an error, then as part of the main request termination, request pool could be destroyed from a subrequest cleanup handler due to the wrong request reference count, followed by a segmentation fault. Found by bad memory allocator simulation.
This commit is contained in:
parent
ecb809305e
commit
b6265d7e2e
@ -2437,6 +2437,8 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
||||
sr->filter_need_in_memory = 1;
|
||||
}
|
||||
|
||||
r->main->count++;
|
||||
|
||||
if (!sr->background) {
|
||||
if (c->data == r && r->postponed == NULL) {
|
||||
c->data = sr;
|
||||
@ -2473,8 +2475,6 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
||||
sr->start_sec = tp->sec;
|
||||
sr->start_msec = tp->msec;
|
||||
|
||||
r->main->count++;
|
||||
|
||||
*psr = sr;
|
||||
|
||||
if (flags & NGX_HTTP_SUBREQUEST_CLONE) {
|
||||
|
Loading…
Reference in New Issue
Block a user