comparison src/http/ngx_http_request.c @ 7632:1d207b77b44a

Simplified subrequest finalization. Now it looks similar to what it was before background subrequests were introduced in 9552758a786e.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 28 Feb 2020 19:54:13 +0300
parents b4dbf8b98f9a
children 8409f9df6219 5b7ec588de48
comparison
equal deleted inserted replaced
7631:b4dbf8b98f9a 7632:1d207b77b44a
2486 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 2486 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
2487 return; 2487 return;
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);
2492 2491
2493 if (r->buffered || r->postponed) { 2492 if (r->buffered || r->postponed) {
2494 2493
2495 if (ngx_http_set_write_handler(r) != NGX_OK) { 2494 if (ngx_http_set_write_handler(r) != NGX_OK) {
2496 ngx_http_terminate_request(r, 0); 2495 ngx_http_terminate_request(r, 0);
2497 } 2496 }
2498 2497
2499 return; 2498 return;
2500 } 2499 }
2501 2500
2502 if (r->background) { 2501 pr = r->parent;
2502
2503 if (r == c->data || r->background) {
2504
2503 if (!r->logged) { 2505 if (!r->logged) {
2506
2507 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
2508
2504 if (clcf->log_subrequest) { 2509 if (clcf->log_subrequest) {
2505 ngx_http_log_request(r); 2510 ngx_http_log_request(r);
2506 } 2511 }
2507 2512
2508 r->logged = 1; 2513 r->logged = 1;
2512 "subrequest: \"%V?%V\" logged again", 2517 "subrequest: \"%V?%V\" logged again",
2513 &r->uri, &r->args); 2518 &r->uri, &r->args);
2514 } 2519 }
2515 2520
2516 r->done = 1; 2521 r->done = 1;
2517 ngx_http_finalize_connection(r); 2522
2518 return; 2523 if (r->background) {
2519 } 2524 ngx_http_finalize_connection(r);
2520 2525 return;
2521 pr = r->parent; 2526 }
2522
2523 if (r == c->data) {
2524 2527
2525 r->main->count--; 2528 r->main->count--;
2526
2527 if (!r->logged) {
2528 if (clcf->log_subrequest) {
2529 ngx_http_log_request(r);
2530 }
2531
2532 r->logged = 1;
2533
2534 } else {
2535 ngx_log_error(NGX_LOG_ALERT, c->log, 0,
2536 "subrequest: \"%V?%V\" logged again",
2537 &r->uri, &r->args);
2538 }
2539
2540 r->done = 1;
2541 2529
2542 if (pr->postponed && pr->postponed->request == r) { 2530 if (pr->postponed && pr->postponed->request == r) {
2543 pr->postponed = pr->postponed->next; 2531 pr->postponed = pr->postponed->next;
2544 } 2532 }
2545 2533