From 354870a502eb9d2a4cc38e8b5274cf571260d0fc Mon Sep 17 00:00:00 2001 From: "Thomas P." Date: Tue, 10 Sep 2024 13:04:31 +0200 Subject: [PATCH] [http_rewrite] Avoid duplicate non-cacheable variable calls for complex expressions When defining a rewrite variable from a non-cacheable variable (set $var $computed_var), I've noticed 2 calls to $computed_var's get_handler (one to determine the total length of the created variable, the other to get the variable contents and copy them into the allocated buffer). Setting the flushed variable seems to address the problem while not breaking any existing test. --- src/http/modules/ngx_http_rewrite_module.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index ff3b68716..be45b2519 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -174,6 +174,7 @@ ngx_http_rewrite_handler(ngx_http_request_t *r) e->quote = 1; e->log = rlcf->log; e->status = NGX_DECLINED; + e->flushed = 1; while (*(uintptr_t *) e->ip) { code = *(ngx_http_script_code_pt *) e->ip;