[nginx] svn commit: r4855 - in branches/stable-1.2: . src/http/modules

mdounin at mdounin.ru mdounin at mdounin.ru
Mon Sep 24 19:00:04 UTC 2012


Author: mdounin
Date: 2012-09-24 19:00:02 +0000 (Mon, 24 Sep 2012)
New Revision: 4855
URL: http://trac.nginx.org/nginx/changeset/4855/nginx

Log:
Merge of r4815: map: fixed optimization of variables as values.

Previous code incorrectly used ctx->var_values as an array of pointers to
ngx_http_variable_value_t, but the array contains structures, not pointers.
Additionally, ctx->var_values inspection failed to properly set var on
match.


Modified:
   branches/stable-1.2/
   branches/stable-1.2/src/http/modules/ngx_http_map_module.c

Index: branches/stable-1.2
===================================================================
--- branches/stable-1.2	2012-09-24 18:58:13 UTC (rev 4854)
+++ branches/stable-1.2	2012-09-24 19:00:02 UTC (rev 4855)

Property changes on: branches/stable-1.2
___________________________________________________________________
Modified: svn:mergeinfo
## -1 +1 ##
-/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4814,4816,4818-4820,4822-4824,4830-4832,4834,4840,4842-4844
+/trunk:4611-4632,4636-4657,4671-4672,4674-4676,4682,4684-4699,4704-4706,4713,4736-4741,4754,4756-4771,4775,4777-4780,4782-4785,4795,4811-4816,4818-4820,4822-4824,4830-4832,4834,4840,4842-4844
\ No newline at end of property
Modified: branches/stable-1.2/src/http/modules/ngx_http_map_module.c
===================================================================
--- branches/stable-1.2/src/http/modules/ngx_http_map_module.c	2012-09-24 18:58:13 UTC (rev 4854)
+++ branches/stable-1.2/src/http/modules/ngx_http_map_module.c	2012-09-24 19:00:02 UTC (rev 4855)
@@ -416,11 +416,12 @@
 
         for (i = 0; i < ctx->var_values.nelts; i++) {
             if (index == (ngx_int_t) var[i].data) {
+                var = &var[i];
                 goto found;
             }
         }
 
-        var = ngx_palloc(ctx->keys.pool, sizeof(ngx_http_variable_value_t));
+        var = ngx_array_push(&ctx->var_values);
         if (var == NULL) {
             return NGX_CONF_ERROR;
         }
@@ -431,13 +432,6 @@
         var->len = 0;
         var->data = (u_char *) index;
 
-        vp = ngx_array_push(&ctx->var_values);
-        if (vp == NULL) {
-            return NGX_CONF_ERROR;
-        }
-
-        *vp = var;
-
         goto found;
     }
 



More information about the nginx-devel mailing list