]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: cache: Remove a useless variable in http_action_req_cache_use
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 7 Oct 2026 15:26:34 +0000 (17:26 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 12 Oct 2026 12:41:03 +0000 (14:41 +0200)
The only case in which the 'detached' variable keeps its default value
of 0, the 'res' variable has to be set to NULL so all the checks on
'detached' that happen later are always true since they are called in a
'if (res && res->secondary_key_signature)' block. The 'detached'
variable can then be removed completely.

src/cache.c

index dde56799657dacadd08505ce4edfe95ca24486ac..83173a87b7cb718116b20f96edcb094b8a393980 100644 (file)
@@ -2695,7 +2695,6 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
         * Vary). */
        if (res) {
                struct appctx *appctx;
-               int detached = 0;
 
                entry_block = block_ptr(res);
                shctx_wrlock(shctx);
@@ -2710,7 +2709,6 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
                         */
                        retain_entry(res);
                        shctx_row_detach(shctx, entry_block);
-                       detached = 1;
                } else {
                        /* p[1] holds the "no-early-hints" opt-out set by parse_cache_use(). */
                        if ((cache->flags & CACHE_CF_EARLY_HINTS) && !rule->arg.act.p[1] &&
@@ -2788,12 +2786,12 @@ enum act_return http_action_req_cache_use(struct act_rule *rule, struct proxy *p
                                         * not from here, see below.
                                         */
                                        to_release = res;
-                                       to_reattach = detached ? block_ptr(res) : NULL;
+                                       to_reattach = block_ptr(res);
                                }
                                else if (sec_entry != res) {
                                        /* The wrong row was added to the hot list. */
                                        to_release = res;
-                                       to_reattach = detached ? block_ptr(res) : NULL;
+                                       to_reattach = block_ptr(res);
                                        shctx_wrlock(shctx);
                                        /* Same as for the primary entry above: retain
                                         * this one under the lock that detaches its