]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: proxy: detach the name node in proxy_free_common() instead
authorWilly Tarreau <w@1wt.eu>
Sat, 19 Apr 2025 08:21:19 +0000 (10:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Apr 2025 08:21:19 +0000 (10:21 +0200)
This changes commit d2a9149f0 ("BUG/MINOR: proxy: always detach a proxy
from the names tree on free()") to be cleaner. AurĂ©lien spotted that
the free(p->id) was indeed already done in proxy_free_common(), which is
called before we delete the node. That's still a bit ugly and it only
works because ebpt_delete() does not dereference the key during the
operation. Better play safe and delete the entry before freeing it,
that's more future-proof.

src/proxy.c

index 48090128d344c04e91a2423fdae8a5bbc7100448..8d87bf85cd5686536a0796dc79ab703f8697c6af 100644 (file)
@@ -213,6 +213,8 @@ static inline void proxy_free_common(struct proxy *px)
        struct lf_expr *lf, *lfb;
        struct eb32_node *node;
 
+       /* note that the node's key points to p->id */
+       ebpt_delete(&px->conf.by_name);
        ha_free(&px->id);
        drop_file_name(&px->conf.file);
        ha_free(&px->check_command);
@@ -414,10 +416,6 @@ void deinit_proxy(struct proxy *p)
 
        free(p->desc);
 
-       /* note that the node's key points to p->id */
-       ebpt_delete(&p->conf.by_name);
-       free(p->id);
-
        task_destroy(p->task);
 
        pool_destroy(p->req_cap_pool);