Sun, 07 Dec 2025 16:31:21 +0100
cleanup compiled location regex
--- a/src/server/daemon/config.c Fri Dec 05 17:37:48 2025 +0100 +++ b/src/server/daemon/config.c Sun Dec 07 16:31:21 2025 +0100 @@ -167,6 +167,8 @@ CxAllocator *allocator = pool_allocator(serverconfig->pool); serverconfig->a = allocator; + serverconfig->destr = cxArrayListCreate(serverconfig->a, NULL, sizeof(ScfgDestr), 32); + serverconfig->listeners = cxLinkedListCreate(serverconfig->a, NULL, CX_STORE_POINTERS); serverconfig->logfiles = cxLinkedListCreate(serverconfig->a, NULL, CX_STORE_POINTERS); serverconfig->host_vs = cxHashMapCreate(serverconfig->a, CX_STORE_POINTERS, 16); @@ -1329,3 +1331,11 @@ } return pb; } + +void server_config_destroy(ServerConfiguration *cfg) { + CxIterator i = cxListIterator(cfg->destr); + cx_foreach(ScfgDestr *, d, i) { + d->destr(d->data); + } + pool_destroy(cfg->pool); +}
--- a/src/server/daemon/config.h Fri Dec 05 17:37:48 2025 +0100 +++ b/src/server/daemon/config.h Sun Dec 07 16:31:21 2025 +0100 @@ -48,6 +48,7 @@ #include "../webdav/webdav.h" #include <cx/linked_list.h> +#include <cx/array_list.h> #include <cx/hash_map.h> #include <cx/mempool.h> #include <cx/string.h> @@ -63,10 +64,17 @@ ServerConfiguration *cfg; } CfgManager; +typedef struct ScfgDestr { + cx_destructor_func destr; + void *data; +} ScfgDestr; + struct ServerConfiguration { pool_handle_t *pool; CxAllocator *a; + CxList *destr; // list of ScfgDestr + ServerConfiguration *next; CxMap *host_vs; // map of all vservers. key is the host name @@ -135,6 +143,8 @@ pblock* config_obj2pblock(pool_handle_t *pool, ConfigNode *obj); +void server_config_destroy(ServerConfiguration *cfg); + #ifdef __cplusplus } #endif
--- a/src/server/daemon/location.c Fri Dec 05 17:37:48 2025 +0100 +++ b/src/server/daemon/location.c Sun Dec 07 16:31:21 2025 +0100 @@ -90,6 +90,10 @@ } +static void location_free_regex(WSLocation *loc) { + regfree(&loc->regex); +} + WSLocation* cfg_location_get(ServerConfiguration *cfg, ConfigNode *obj) { const CxAllocator *a = cfg->a; @@ -134,6 +138,12 @@ log_ereport(LOG_FAILURE, "Location: cannot compile regex pattern %s", match_str.ptr); return NULL; } + ScfgDestr destr; + destr.destr = (cx_destructor_func)location_free_regex; + destr.data = location; + if(cxListAdd(cfg->destr, &destr)) { + return NULL; + } } ConfigNode *dir = obj->children_begin;
--- a/src/server/daemon/webserver.c Fri Dec 05 17:37:48 2025 +0100 +++ b/src/server/daemon/webserver.c Sun Dec 07 16:31:21 2025 +0100 @@ -370,7 +370,7 @@ cx_foreach(HttpListener *, ls, i) { http_listener_destroy(ls); } - pool_destroy(scfg->pool); + server_config_destroy(scfg); http_listener_global_shutdown();