CLEANUP: proxy: detach the name node in proxy_free_common() instead

This changes commit d2a9149f0 ("BUG/MINOR: proxy: always detach a proxy
from the names tree on free()") to be cleaner. Aurlien 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.
This commit is contained in:
Willy Tarreau 2025-04-19 10:21:19 +02:00
parent d2a9149f09
commit 5763a891a9

View 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);