]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stktable: add stktable_deinit function
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 16 Nov 2023 15:17:12 +0000 (16:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 18 Nov 2023 10:16:21 +0000 (11:16 +0100)
Adding sktable_deinit() helper function to properly cleanup a sticktable
that was initialized using stktable_init().

include/haproxy/stick_table.h
src/proxy.c
src/stick_table.c

index e5ebecd7a7faaeb1e08ed1b9025b6e3d17f1647d..320043726c3cea33c8024d0fd8f6e65bd9964f6c 100644 (file)
@@ -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);
index 001fe0344bdf8d07fec819c2e733acbaead4c486..3407168d13c65bb4debb547f0b0a7f5a47b937dc 100644 (file)
@@ -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);
index b97114c3040a26a0d5fb712bb8720cb2fec7a171..26ea97addd3255c2b9f066763f8746a1a86caa5a 100644 (file)
@@ -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
  */