40 int init_resource_pools(void) { |
40 int init_resource_pools(void) { |
41 resource_pool_types = ucx_map_new(4); |
41 resource_pool_types = ucx_map_new(4); |
42 return resource_pool_types ? 0 : 1; |
42 return resource_pool_types ? 0 : 1; |
43 } |
43 } |
44 |
44 |
|
45 int resourcepool_register_type(const char *type_name, ResourceType *type_info) { |
|
46 if(ucx_map_cstr_put(resource_pool_types, type_name, type_info)) { |
|
47 log_ereport(LOG_CATASTROPHE, "resourcepool_register_type: OOM"); |
|
48 return 1; |
|
49 } |
|
50 return 0; |
|
51 } |
|
52 |
45 |
53 |
46 |
54 |
47 int resourcepool_new(ServerConfiguration *cfg, scstr_t type, scstr_t name, ConfigNode *node) { |
55 int resourcepool_new(ServerConfiguration *cfg, scstr_t type, scstr_t name, ConfigNode *node) { |
48 ResourceType *restype = ucx_map_sstr_get(resource_pool_types, type); |
56 ResourceType *restype = ucx_map_sstr_get(resource_pool_types, type); |
49 if(!restype) { |
57 if(!restype) { |
65 log_ereport(LOG_FAILURE, "resourcepool_new: OOM"); |
73 log_ereport(LOG_FAILURE, "resourcepool_new: OOM"); |
66 return 1; |
74 return 1; |
67 } |
75 } |
68 respool->pool = cfg->pool; |
76 respool->pool = cfg->pool; |
69 |
77 |
70 void *respool_data = restype->init(cfg->pool, param); |
78 void *respool_data = restype->init(cfg->pool, name.ptr, param); |
71 if(!respool_data) { |
79 if(!respool_data) { |
72 log_ereport(LOG_FAILURE, "Cannot create resource pool data: pool: %s type: %s", name.ptr, type.ptr); |
80 log_ereport(LOG_FAILURE, "Cannot create resource pool data: pool: %s type: %s", name.ptr, type.ptr); |
73 return 1; |
81 return 1; |
74 } |
82 } |
75 |
83 |