# HG changeset patch # User Olaf Wintermann # Date 1652004478 -7200 # Node ID 78ce9733a54f0ad8146c83b8b3a3025218fa5577 # Parent ebd1e67c3d5f7cdc2c61e6b2d23d6a62b0ac1420 fix resource pool memory management diff -r ebd1e67c3d5f -r 78ce9733a54f src/server/daemon/resourcepool.c --- a/src/server/daemon/resourcepool.c Sun May 08 11:52:52 2022 +0200 +++ b/src/server/daemon/resourcepool.c Sun May 08 12:07:58 2022 +0200 @@ -87,6 +87,10 @@ respool->min = 4; // TODO: get from node respool->max = RESOURCE_POOL_MAX_DEFAULT; // TODO: get from node + respool->numcreated = 0; + respool->numresources = 0; + + // don't allow too large resource pools // this prevents the need to check malloc integer overflows if(respool->max > RESOURCE_POOL_MAX_ALLOC) { @@ -141,7 +145,7 @@ if(resourceData) { respool->numcreated++; - resource = pool_malloc(sn->pool, sizeof(ResourceDataPrivate)); + resource = pool_malloc(respool->pool, sizeof(ResourceDataPrivate)); if(resource) { resource->data.data = respool->type->getresourcedata(resourceData); resource->data.resourcepool = respool; diff -r ebd1e67c3d5f -r 78ce9733a54f src/server/plugins/postgresql/resource.c --- a/src/server/plugins/postgresql/resource.c Sun May 08 11:52:52 2022 +0200 +++ b/src/server/plugins/postgresql/resource.c Sun May 08 12:07:58 2022 +0200 @@ -115,6 +115,7 @@ if(res->connection) { PQfinish(res->connection); } + pool_free(pg->pool, res); } int pg_resourcepool_prepare(PgResourcePool *pg, PgResource *res) {