[PATCH] ngx_upstream do not cleanup file buffers in subrequest

magz nginx-forum at nginx.us
Wed Mar 9 22:28:32 MSK 2011


Forgot  include the check to the patch :)

cat ngx_keep_tempfile_flag.patch 
diff -Nuarp nginx-0.9.5/src/http/ngx_http_core_module.c
nginx-0.9.5_new/src/http/ngx_http_core_module.c
--- nginx-0.9.5/src/http/ngx_http_core_module.c	2011-01-20
07:31:24.000000000 -0800
+++ nginx-0.9.5_new/src/http/ngx_http_core_module.c	2011-03-09
07:22:45.000000000 -0800
@@ -2230,6 +2230,7 @@ ngx_http_subrequest(ngx_http_request_t *
 
     sr->subrequest_in_memory = (flags & NGX_HTTP_SUBREQUEST_IN_MEMORY)
!= 0;
     sr->waited = (flags & NGX_HTTP_SUBREQUEST_WAITED) != 0;
+    sr->keep_temp_file = (flags & NGX_HTTP_REQUEST_KEEP_TEMP_FILE) !=
0;
 
     sr->unparsed_uri = r->unparsed_uri;
     sr->method_name = ngx_http_core_get_method;
diff -Nuarp nginx-0.9.5/src/http/ngx_http_request.h
nginx-0.9.5_new/src/http/ngx_http_request.h
--- nginx-0.9.5/src/http/ngx_http_request.h	2011-01-20
02:37:58.000000000 -0800
+++ nginx-0.9.5_new/src/http/ngx_http_request.h	2011-03-09
07:21:25.000000000 -0800
@@ -61,6 +61,8 @@
 #define NGX_HTTP_SUBREQUEST_IN_MEMORY      2
 #define NGX_HTTP_SUBREQUEST_WAITED         4
 #define NGX_HTTP_LOG_UNSAFE                8
+#define NGX_HTTP_REQUEST_KEEP_TEMP_FILE    16
+
 
 
 #define NGX_HTTP_OK                        200
@@ -461,6 +463,7 @@ struct ngx_http_request_s {
 
     unsigned                          subrequest_in_memory:1;
     unsigned                          waited:1;
+    unsigned			      keep_temp_file:1;
 
 #if (NGX_HTTP_CACHE)
     unsigned                          cached:1;
--- nginx-0.9.5/src/http/ngx_http_upstream.c	2010-07-28
08:56:56.000000000 -0700
+++ nginx-0.9.5_new/src/http/ngx_http_upstream.c	2011-03-09
07:30:30.000000000 -0800
@@ -2030,7 +2033,7 @@ ngx_http_upstream_send_response(ngx_http
 
     u->header_sent = 1;
 
-    if (r->request_body && r->request_body->temp_file) {
+    if (r->request_body && r->request_body->temp_file &&
!r->keep_temp_file) {
         ngx_pool_run_cleanup_file(r->pool,
r->request_body->temp_file->file.fd);
         r->request_body->temp_file->file.fd = NGX_INVALID_FILE;
     }

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,181400,181740#msg-181740




More information about the nginx mailing list