MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / try_add_sql_pool

Function try_add_sql_pool

db/sqlpool.c:161–184  ·  view source on GitHub ↗

** WARNING: The "try_add_sql_pool" function assumes the hash lock is already ** held. */

Source from the content-addressed store, hash-verified

159** held.
160*/
161static int try_add_sql_pool(const char *zName, int nThreads,
162 struct thdpool *pool)
163{
164 if (pool == NULL) return -1; /* cannot add, invalid pool */
165 if (sqlengine_pool_hash == NULL)
166 {
167 sqlengine_pool_hash = hash_init_strptr(offsetof(pool_entry_t, zName));
168 if (sqlengine_pool_hash == NULL) return -2; /* OOM (?) */
169 }
170 const char *zEntryName = (zName != NULL) ?
171 thdpool_get_name(pool) : SQL_POOL_DEFLT_NAME;
172 pool_entry_t *entry = hash_find(sqlengine_pool_hash, &zEntryName);
173 if (entry != NULL) return -3; /* cannot add, already present */
174 entry = calloc(1, sizeof(pool_entry_t));
175 if (entry == NULL) return -4; /* OOM */
176 entry->zName = zEntryName;
177 entry->nThreads = nThreads; /* as specified */
178 entry->pPool = pool;
179 if (hash_add(sqlengine_pool_hash, entry) != 0) {
180 free(entry);
181 return -5;
182 }
183 return 0;
184}
185
186int get_default_sql_pool_max_threads(void)
187{

Callers 2

get_default_sql_poolFunction · 0.85
get_named_sql_poolFunction · 0.85

Calls 6

hash_init_strptrFunction · 0.85
thdpool_get_nameFunction · 0.85
hash_findFunction · 0.85
callocFunction · 0.85
hash_addFunction · 0.85
freeFunction · 0.85

Tested by

no test coverage detected