2011年3月9日星期三

Re: [PATCH] ngx_upstream do not cleanup file buffers in subrequest

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


_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx

没有评论:

发表评论