From: Aurelien DARRAGON Date: Thu, 16 Nov 2023 15:17:12 +0000 (+0100) Subject: MINOR: stktable: add stktable_deinit function X-Git-Tag: v2.9-dev10~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e10cf61099a654b5eaf4b92e0e01e315fda6d116;p=thirdparty%2Fhaproxy.git MINOR: stktable: add stktable_deinit function Adding sktable_deinit() helper function to properly cleanup a sticktable that was initialized using stktable_init(). --- diff --git a/include/haproxy/stick_table.h b/include/haproxy/stick_table.h index e5ebecd7a7..320043726c 100644 --- a/include/haproxy/stick_table.h +++ b/include/haproxy/stick_table.h @@ -47,6 +47,7 @@ int stksess_kill(struct stktable *t, struct stksess *ts, int decrefcount); int stktable_get_key_shard(struct stktable *t, const void *key, size_t len); int stktable_init(struct stktable *t, char **err_msg); +void stktable_deinit(struct stktable *t); int stktable_parse_type(char **args, int *idx, unsigned long *type, size_t *key_size, const char *file, int linenum); int parse_stick_table(const char *file, int linenum, char **args, struct stktable *t, char *id, char *nid, struct peers *peers); diff --git a/src/proxy.c b/src/proxy.c index 001fe0344b..3407168d13 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -389,8 +389,7 @@ void free_proxy(struct proxy *p) pool_destroy(p->req_cap_pool); pool_destroy(p->rsp_cap_pool); - if (p->table) - pool_destroy(p->table->pool); + stktable_deinit(p->table); HA_RWLOCK_DESTROY(&p->lbprm.lock); HA_RWLOCK_DESTROY(&p->lock); diff --git a/src/stick_table.c b/src/stick_table.c index b97114c304..26ea97addd 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -865,6 +865,19 @@ int stktable_init(struct stktable *t, char **err_msg) return 0; } +/* Performs stick table cleanup: it's meant to be called after the table + * has been initialized ith stktable_init(), else it will lead to undefined + * behavior. + * + * However it does not free the table pointer itself + */ +void stktable_deinit(struct stktable *t) +{ + if (!t) + return; + pool_destroy(t->pool); +} + /* * Configuration keywords of known table types */