[nginx] Range filter: only initialize ctx->ranges in main request.

Maxim Dounin mdounin at mdounin.ru
Fri Nov 11 19:10:50 UTC 2016


details:   http://hg.nginx.org/nginx/rev/2decd6b34306
branches:  
changeset: 6798:2decd6b34306
user:      hucongcong <hucong.c at foxmail.com>
date:      Thu Nov 10 10:44:52 2016 +0800
description:
Range filter: only initialize ctx->ranges in main request.

It is not necessary to initialize ctx->ranges in all request, because
ctx->ranges in subrequest will be reassigned to ctx->ranges of main
request.

diffstat:

 src/http/modules/ngx_http_range_filter_module.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (29 lines):

diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -224,12 +224,6 @@ parse:
 
     ctx->offset = r->headers_out.content_offset;
 
-    if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t))
-        != NGX_OK)
-    {
-        return NGX_ERROR;
-    }
-
     ranges = r->single_range ? 1 : clcf->max_ranges;
 
     switch (ngx_http_range_parse(r, ctx, ranges)) {
@@ -291,6 +285,12 @@ ngx_http_range_parse(ngx_http_request_t 
         }
     }
 
+    if (ngx_array_init(&ctx->ranges, r->pool, 1, sizeof(ngx_http_range_t))
+        != NGX_OK)
+    {
+        return NGX_ERROR;
+    }
+
     p = r->headers_in.range->value.data + 6;
     size = 0;
     content_length = r->headers_out.content_length_n;



More information about the nginx-devel mailing list