diff -r cfb588e27198 -r 25e5b771677d src/server/daemon/resourcepool.c --- a/src/server/daemon/resourcepool.c Tue Feb 01 20:07:42 2022 +0100 +++ b/src/server/daemon/resourcepool.c Thu Feb 03 17:26:08 2022 +0100 @@ -145,6 +145,7 @@ if(resource) { resource->data.data = respool->type->getresourcedata(resourceData); resource->data.resourcepool = respool; + resource->resdata = resourceData; } else { respool->type->freeresource(respool->data, resourceData); log_ereport(LOG_CATASTROPHE, "resourcepool_lookup: OOM"); @@ -176,6 +177,10 @@ } else { err = 1; } + + if(respool->type->prepare(respool->data, resource->resdata)) { + err = -1; + } } if(err) { @@ -188,14 +193,17 @@ pthread_mutex_unlock(&respool->lock); - - return &resource->data; + return (ResourceData*)resource; } void resourcepool_free(Session *sn, Request *rq, ResourceData *resource) { ResourceDataPrivate *res = (ResourceDataPrivate*)resource; ResourcePool *respool = resource->resourcepool; + if(respool->type->finish(respool->data, res->resdata)) { + log_ereport(LOG_FAILURE, "resourcepool_free: finish failed"); + } + pthread_mutex_lock(&respool->lock); if(respool->numresources >= respool->resalloc) {