MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / mod_init

Function mod_init

modules/sql_cacher/sql_cacher.c:1370–1458  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1368}
1369
1370static int mod_init(void)
1371{
1372 cache_entry_t *c_entry;
1373 db_handlers_t *db_hdls;
1374 char use_timer = 0;
1375
1376 if (full_caching_expire <= 0) {
1377 full_caching_expire = DEFAULT_FULL_CACHING_EXPIRE;
1378 LM_WARN("Invalid full_caching_expire parameter, "
1379 "setting default value: %d sec\n", DEFAULT_FULL_CACHING_EXPIRE);
1380 }
1381 if (reload_interval <= 0 || reload_interval >= full_caching_expire) {
1382 reload_interval = DEFAULT_RELOAD_INTERVAL;
1383 LM_WARN("Invalid reload_interval parameter, "
1384 "setting default value: %d sec\n", DEFAULT_RELOAD_INTERVAL);
1385 }
1386 if(!entry_list){
1387 entry_list = shm_malloc(sizeof(cache_entry_t*));
1388 if (!entry_list) {
1389 LM_ERR("No more memory for cache entries list\n");
1390 return -1;
1391 }
1392 *entry_list = NULL;
1393 }
1394 queries_in_progress = shm_malloc(sizeof(struct queried_key *));
1395 if (!queries_in_progress) {
1396 LM_ERR("No more memory for queries_in_progress list\n");
1397 return -1;
1398 }
1399 *queries_in_progress = NULL;
1400
1401 queries_lock = lock_alloc();
1402 if (!queries_lock) {
1403 LM_ERR("No more memory for queries_lock\n");
1404 return -1;
1405 }
1406 if (!lock_init(queries_lock)) {
1407 LM_ERR("Failed to init queries_lock\n");
1408 return -1;
1409 }
1410
1411 sql_srg = sr_register_group( CHAR_INT("sql_cacher"), 0 /*not public*/);
1412 if (sql_srg==NULL) {
1413 LM_ERR("failed to create sql_cacher group for 'status-report'");
1414 return -1;
1415 }
1416
1417 c_entry = *entry_list;
1418 while (c_entry) {
1419 if ((db_hdls = db_init_test_conn(c_entry)) == NULL) {
1420 LM_ERR("Failed to validate db conns for cache entry\n");
1421 return -1;
1422 }
1423
1424 if (!c_entry->on_demand) {
1425 use_timer = 1;
1426 c_entry->expire = full_caching_expire;
1427 c_entry->ref_lock = lock_init_rw();

Callers

nothing calls this directly

Calls 7

shm_mallocFunction · 0.85
lock_initFunction · 0.85
sr_register_groupFunction · 0.85
db_init_test_connFunction · 0.85
lock_init_rwFunction · 0.85
sr_register_identifierFunction · 0.85
register_timerFunction · 0.85

Tested by

no test coverage detected