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

Function mod_init

modules/config/config.c:170–270  ·  view source on GitHub ↗

* init module function */

Source from the content-addressed store, hash-verified

168 * init module function
169 */
170static int mod_init(void)
171{
172 int n;
173 str srg_data = str_init("no data loaded");
174 int srg_status = SR_STATUS_NO_DATA;
175
176 LM_NOTICE("initializing config module ...\n");
177 init_db_url(config_db_url , 1 /*can be null*/);
178 config_table.len = strlen(config_table.s);
179 config_name_col.len = strlen(config_name_col.s);
180 config_value_col.len = strlen(config_value_col.s);
181 config_desc_col.len = strlen(config_desc_col.s);
182
183 if(db_bind_mod(&config_db_url, &config_db_func) == -1) {
184 LM_ERR("Failed bind to database\n");
185 return -1;
186 }
187
188 if (!DB_CAPABILITY(config_db_func, DB_CAP_QUERY|DB_CAP_FETCH|DB_CAP_INSERT_UPDATE)) {
189 LM_ERR("Database module does not implement all functions"
190 " needed by config module\n");
191 return -1;
192 }
193
194 config_db_con = config_db_func.init(&config_db_url);
195 if (!config_db_con) {
196 LM_ERR("Failed to connect to database\n");
197 return -1;
198 }
199
200 /*verify table versions */
201 if(db_check_table_version(&config_db_func, config_db_con,
202 &config_table, CONFIG_TABLE_VERSION) < 0) {
203 LM_ERR("error during table version check\n");
204 return -1;
205 }
206
207 config_lock = lock_alloc();
208 if (!config_lock || !lock_init(config_lock)) {
209 LM_ERR("could not allocate config lock\n");
210 return -1;
211 }
212
213 config_srg = sr_register_group( CHAR_INT("config"), 0 /*not public*/);
214 if (!config_srg) {
215 LM_ERR("failed to create config group for 'status-report'\n");
216 return -1;
217 }
218
219 config_hash = shm_malloc(sizeof *config_hash);
220 if (!config_hash) {
221 LM_ERR("oom for config_hash\n");
222 return -1;
223 }
224 *config_hash = 0;
225
226 if (config_rpm_enable) {
227 /* if we are using cache, we need to fetch our dr zone */

Callers

nothing calls this directly

Calls 9

db_bind_modFunction · 0.85
db_check_table_versionFunction · 0.85
lock_initFunction · 0.85
sr_register_groupFunction · 0.85
shm_mallocFunction · 0.85
rpm_init_memFunction · 0.85
rpm_key_getFunction · 0.85
hash_init_locksFunction · 0.85
sr_register_identifierFunction · 0.85

Tested by

no test coverage detected