comparison src/http/ngx_http_upstream.c @ 7070:f583559aadc7

Upstream: keep request body file from removal if requested. The new request flag "preserve_body" indicates that the request body file should not be removed by the upstream module because it may be used later by a subrequest. The flag is set by the SSI (ticket #585), addition and slice modules. Additionally, it is also set by the upstream module when a background cache update subrequest is started to prevent the request body file removal after an internal redirect. Only the main request is now allowed to remove the file.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 19 Jul 2017 20:38:17 +0300
parents e3723f2a11b7
children 2a288909abc6
comparison
equal deleted inserted replaced
7069:863b862534d7 7070:f583559aadc7
1075 1075
1076 if (!r->cached || !r->cache->background) { 1076 if (!r->cached || !r->cache->background) {
1077 return NGX_OK; 1077 return NGX_OK;
1078 } 1078 }
1079 1079
1080 if (r == r->main) {
1081 r->preserve_body = 1;
1082 }
1083
1080 if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL, 1084 if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL,
1081 NGX_HTTP_SUBREQUEST_CLONE 1085 NGX_HTTP_SUBREQUEST_CLONE
1082 |NGX_HTTP_SUBREQUEST_BACKGROUND) 1086 |NGX_HTTP_SUBREQUEST_BACKGROUND)
1083 != NGX_OK) 1087 != NGX_OK)
1084 { 1088 {
2855 } 2859 }
2856 2860
2857 u->pipe->downstream_error = 1; 2861 u->pipe->downstream_error = 1;
2858 } 2862 }
2859 2863
2860 if (r->request_body && r->request_body->temp_file) { 2864 if (r->request_body && r->request_body->temp_file
2865 && r == r->main && !r->preserve_body)
2866 {
2861 ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd); 2867 ngx_pool_run_cleanup_file(r->pool, r->request_body->temp_file->file.fd);
2862 r->request_body->temp_file->file.fd = NGX_INVALID_FILE; 2868 r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
2863 } 2869 }
2864 2870
2865 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 2871 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);