| 349 | |
| 350 | |
| 351 | static int mod_init(void) |
| 352 | { |
| 353 | LM_INFO("Load-Balancer module - initializing\n"); |
| 354 | |
| 355 | init_db_url( db_url , 0 /*cannot be null*/); |
| 356 | |
| 357 | /* Load dialog API */ |
| 358 | if (load_dlg_api(&lb_dlg_binds) != 0) { |
| 359 | LM_ERR("Can't load dialog hooks\n"); |
| 360 | return -1; |
| 361 | } |
| 362 | |
| 363 | if (fetch_freeswitch_stats) { |
| 364 | if (load_fs_api(&fs_api) == -1) { |
| 365 | LM_ERR("failed to load the FS API!\n"); |
| 366 | return -1; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | /* data pointer in shm */ |
| 371 | curr_data = (struct lb_data**)shm_malloc( sizeof(struct lb_data*) ); |
| 372 | if (curr_data==0) { |
| 373 | LM_CRIT("failed to get shm mem for data ptr\n"); |
| 374 | return -1; |
| 375 | } |
| 376 | *curr_data = 0; |
| 377 | |
| 378 | /* create & init lock */ |
| 379 | if ((ref_lock = lock_init_rw()) == NULL) { |
| 380 | LM_CRIT("failed to init lock\n"); |
| 381 | return -1; |
| 382 | } |
| 383 | |
| 384 | if (init_lb_bls()) { |
| 385 | LM_ERR("BL INIT failed\n"); |
| 386 | return -1; |
| 387 | } |
| 388 | |
| 389 | /* init and open DB connection */ |
| 390 | if (init_lb_db(&db_url, table_name)!=0) { |
| 391 | LM_ERR("failed to initialize the DB support\n"); |
| 392 | return -1; |
| 393 | } |
| 394 | |
| 395 | /* load data */ |
| 396 | if ( lb_reload_data()!=0 ) { |
| 397 | LM_CRIT("failed to load load-balancing data\n"); |
| 398 | return -1; |
| 399 | } |
| 400 | |
| 401 | /* close DB connection */ |
| 402 | lb_close_db(); |
| 403 | |
| 404 | /* arm a function for probing */ |
| 405 | if (lb_prob_interval) { |
| 406 | /* load TM API */ |
| 407 | if (load_tm_api(&lb_tmb)!=0) { |
| 408 | LM_ERR("can't load TM API\n"); |
nothing calls this directly
no test coverage detected