int init_data(void) { int *p; rules_hash = (dpl_id_p *)shm_malloc(2*sizeof(dpl_id_p)); if(!rules_hash) { LM_ERR("out of shm memory\n"); return -1; } rules_hash[0] = rules_hash[1] = 0; p = (int *)shm_malloc(2*sizeof(int)); if(!p){ LM_ERR("out of shm memory\n"); return -1; } crt_idx = p; next_idx = p+1; *crt_idx = *next_idx = 0; LM_DBG("trying to initialize data from db\n"); if(init_db_data() != 0) return -1; return 0; }
static int child_init(int rank) { dp_connection_list_p el; /* only process with rank 0 loads data */ if (rank != 1) return 0; /*Connect to DB s and get rules*/ for(el = dp_conns; el; el = el->next){ if (init_db_data(el) != 0) { LM_ERR("Unable to init db data\n"); shm_free(el); return -1; } } dp_disconnect_all_db(); return 0; }
static int child_init(int rank) { dp_connection_list_p el; /* only process with rank PROC_MAIN(0) loads data */ if (rank != PROC_MAIN) return 0; /*Connect to DB s and get rules*/ for(el = dp_conns; el; el = el->next){ if (init_db_data(el) != 0) { /* all el shall be freed in mod destroy */ LM_ERR("Unable to init db data\n"); return -1; } } dp_disconnect_all_db(); return 0; }