Thu, 11 Aug 2022 20:21:13 +0200
add global resource lookup function
src/server/daemon/resourcepool.c | file | annotate | diff | comparison | revisions | |
src/server/public/nsapi.h | file | annotate | diff | comparison | revisions |
--- a/src/server/daemon/resourcepool.c Wed Aug 10 21:01:54 2022 +0200 +++ b/src/server/daemon/resourcepool.c Thu Aug 11 20:21:13 2022 +0200 @@ -114,11 +114,9 @@ return 0; } -ResourceData* resourcepool_lookup(Session *sn, Request *rq, const char *name, int flags) { - NSAPIRequest *request = (NSAPIRequest*)rq; - NSAPISession *session = (NSAPISession*)sn; - ServerConfiguration *cfg = session->config; - +static ResourceData* s_resourcepool_lookup(ServerConfiguration *cfg, Request *opt_rq, Session *opt_sn, const char *name, int flags) { + NSAPIRequest *request = (NSAPIRequest*)opt_rq; + NSAPISession *session = (NSAPISession*)opt_sn; ResourceDataPrivate *resource = NULL; // was this resource already used by this request? @@ -170,7 +168,7 @@ // for cleanup later int err = 0; if(resource) { - if(request) { + if(request && session) { if(!request->resources) { request->resources = ucx_map_new_a(&session->allocator, 8); } @@ -202,6 +200,16 @@ return (ResourceData*)resource; } +ResourceData* resourcepool_cfg_lookup(ServerConfiguration *cfg, const char *name, int flags) { + return s_resourcepool_lookup(cfg, NULL, NULL, name, flags); +} + +ResourceData* resourcepool_lookup(Session *sn, Request *rq, const char *name, int flags) { + NSAPISession *session = (NSAPISession*)sn; + ServerConfiguration *cfg = session->config; + return s_resourcepool_lookup(cfg, rq, sn, name, flags); +} + void resourcepool_free(Session *sn, Request *rq, ResourceData *resource) { ResourceDataPrivate *res = (ResourceDataPrivate*)resource; ResourcePool *respool = resource->resourcepool;
--- a/src/server/public/nsapi.h Wed Aug 10 21:01:54 2022 +0200 +++ b/src/server/public/nsapi.h Thu Aug 11 20:21:13 2022 +0200 @@ -1621,6 +1621,7 @@ // resource pool ResourceData* resourcepool_lookup(Session *sn, Request *rq, const char *name, int flags); +ResourceData* resourcepool_cfg_lookup(ServerConfiguration *cfg, const char *name, int flags); void resourcepool_free(Session *sn, Request *rq, ResourceData *resource); // utils