src/server/daemon/resourcepool.c

changeset 490
d218607f5a7e
parent 463
4fd523fff13b
equal deleted inserted replaced
489:921f83a8943f 490:d218607f5a7e
37 #define RESOURCE_POOL_MAX_ALLOC 268435455 37 #define RESOURCE_POOL_MAX_ALLOC 268435455
38 38
39 static CxMap *resource_pool_types; 39 static CxMap *resource_pool_types;
40 40
41 int init_resource_pools(void) { 41 int init_resource_pools(void) {
42 resource_pool_types = cxHashMapCreate(cxDefaultAllocator, 4); 42 resource_pool_types = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 4);
43 return resource_pool_types ? 0 : 1; 43 return resource_pool_types ? 0 : 1;
44 } 44 }
45 45
46 int resourcepool_register_type(const char *type_name, ResourceType *type_info) { 46 int resourcepool_register_type(const char *type_name, ResourceType *type_info) {
47 if(cxMapPut(resource_pool_types, cx_hash_key_str(type_name), type_info)) { 47 if(cxMapPut(resource_pool_types, cx_hash_key_str(type_name), type_info)) {
177 // for cleanup later 177 // for cleanup later
178 int err = 0; 178 int err = 0;
179 if(resource) { 179 if(resource) {
180 if(request && session) { 180 if(request && session) {
181 if(!request->resources) { 181 if(!request->resources) {
182 request->resources = cxHashMapCreate(pool_allocator(session->sn.pool), 8); 182 request->resources = cxHashMapCreate(pool_allocator(session->sn.pool), CX_STORE_POINTERS, 8);
183 } 183 }
184 184
185 if(request->resources) { 185 if(request->resources) {
186 if(cxMapPut(request->resources, cx_hash_key_str(name), resource)) { 186 if(cxMapPut(request->resources, cx_hash_key_str(name), resource)) {
187 err = 1; 187 err = 1;
224 ResourceDataPrivate *res = (ResourceDataPrivate*)resource; 224 ResourceDataPrivate *res = (ResourceDataPrivate*)resource;
225 ResourcePool *respool = resource->resourcepool; 225 ResourcePool *respool = resource->resourcepool;
226 226
227 if(nsapi_rq && !nsapi_rq->finished) { 227 if(nsapi_rq && !nsapi_rq->finished) {
228 // request processing still ongoing and SAFs will be executed 228 // request processing still ongoing and SAFs will be executed
229 if(!cxMapRemove(nsapi_rq->resources, cx_hash_key_str(respool->name))) { 229 if(!cxMapRemoveAndGet(nsapi_rq->resources, cx_hash_key_str(respool->name))) {
230 log_ereport(LOG_FAILURE, "resourcepool_free: cannot remove resource from request: potential double free"); 230 log_ereport(LOG_FAILURE, "resourcepool_free: cannot remove resource from request: potential double free");
231 } 231 }
232 } 232 }
233 // else: safe to ignore nsapi_rq->resources 233 // else: safe to ignore nsapi_rq->resources
234 234

mercurial