static int child_init(int rank) { int pid; if (rank!=PROC_MAIN) return 0; if(!reg_db_url.s || reg_db_url.len<=0) return 0; pid=fork_process(PROC_TIMER, "TIMER UAC REG", 1); if (pid<0) { LM_ERR("failed to register timer routine as process\n"); return -1; } if (pid==0){ /* child */ /* initialize the config framework */ if (cfg_child_init()) return -1; uac_reg_load_db(); uac_reg_timer(0); for(;;){ /* update the local config framework structures */ cfg_update(); sleep(reg_timer_interval); uac_reg_timer(get_ticks()); } } /* parent */ return 0; }
static void rpc_uac_reg_reload(rpc_t* rpc, void* ctx) { int ret; if(uac_reg_ht_shift()<0) { rpc->fault(ctx, 500, "Failed to shift records - check log messages"); return; } lock_get(_reg_htable_gc_lock); ret = uac_reg_load_db(); lock_release(_reg_htable_gc_lock); if(ret<0) { rpc->fault(ctx, 500, "Failed to reload records - check log messages"); return; } }