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

Function mod_init

modules/cachedb_local/cachedb_local.c:564–782  ·  view source on GitHub ↗

* init module function */

Source from the content-addressed store, hash-verified

562 * init module function
563 */
564static int mod_init(void)
565{
566 cachedb_engine cde;
567 cachedb_con *con;
568 str url=str_init("local://");
569 str name=str_init("local");
570
571 url_lst_t *it=url_list, *foo=NULL;
572 lcache_col_t *default_col, *col_it;
573
574 lcache_rpm_cache_t *rpm_cache;
575
576 memset(&cde, 0, sizeof cde);
577
578 /* register the cache system */
579 cde.name = cache_mod_name;
580
581 cde.cdb_func.init = lcache_init;
582 cde.cdb_func.destroy = lcache_destroy;
583 cde.cdb_func.get = lcache_htable_fetch;
584 cde.cdb_func.get_counter = lcache_htable_fetch_counter;
585 cde.cdb_func.set = lcache_htable_insert;
586 cde.cdb_func.remove = lcache_htable_remove;
587 cde.cdb_func.add = lcache_htable_add;
588 cde.cdb_func.sub = lcache_htable_sub;
589 cde.cdb_func.is_replicated = lcache_is_replicated;
590 cde.cdb_func.iter_keys = lcache_htable_iter_keys;
591
592 cde.cdb_func.capability = CACHEDB_CAP_BINARY_VALUE;
593
594 if(cache_clean_period <= 0 )
595 {
596 LM_ERR("Wrong parameter cache_clean_period - need a positive value\n");
597 return -1;
598 }
599
600 if( register_cachedb(&cde)< 0)
601 {
602 LM_ERR("failed to register to core memory store interface\n");
603 return -1;
604 }
605
606 if (lcache_rpm_enable) {
607 if (rpm_init_mem() < 0) {
608 LM_ERR("could not initilize restart persistent memory!\n");
609 return -1;
610 }
611 lcache_rpm_cache = (lcache_rpm_cache_t *)rpm_key_get("cachedb_local");
612 if (!lcache_rpm_cache)
613 LM_INFO("starting cachedb_local with empty rpm cache\n");
614
615 LM_INFO("using %ld MB of restart-persistent memory, allocator: %s\n",
616 rpm_mem_size/1024/1024, mm_str(mem_allocator_rpm));
617 }
618
619 for ( col_it=lcache_collection; col_it; col_it=col_it->next ) {
620 if ( !memcmp(col_it->col_name.s, DEFAULT_COLLECTION_NAME,
621 sizeof(DEFAULT_COLLECTION_NAME) - 1) ) {

Callers

nothing calls this directly

Calls 14

register_cachedbFunction · 0.85
rpm_init_memFunction · 0.85
rpm_key_getFunction · 0.85
shm_mallocFunction · 0.85
lcache_initFunction · 0.85
cachedb_put_connectionFunction · 0.85
clean_rpm_cache_oldFunction · 0.85
get_rpm_cacheFunction · 0.85
add_head_rpm_cacheFunction · 0.85
lcache_htable_destroyFunction · 0.85
lcache_htable_initFunction · 0.85
fix_rpm_cache_entriesFunction · 0.85

Tested by

no test coverage detected