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

Function mod_init

modules/ratelimit/ratelimit.c:380–495  ·  view source on GitHub ↗

initialize ratelimit module */

Source from the content-addressed store, hash-verified

378
379/* initialize ratelimit module */
380static int mod_init(void)
381{
382 unsigned int n;
383
384 LM_INFO("Ratelimit module - initializing ...\n");
385
386 if (rl_timer_interval < 0) {
387 LM_ERR("invalid timer interval\n");
388 return -1;
389 }
390 if (rl_expire_time < 0) {
391 LM_ERR("invalid expire time\n");
392 return -1;
393 }
394
395 if (rl_repl_cluster < 0) {
396 LM_ERR("Invalid replication_cluster, must be 0 or a positive cluster id\n");
397 return -1;
398 }
399
400 if (rl_repl_cluster && load_clusterer_api(&clusterer_api) != 0 ){
401 LM_DBG("failed to find clusterer API - is clusterer module loaded?\n");
402 return -1;
403 }
404
405 if (db_url.s) {
406 db_url.len = strlen(db_url.s);
407 db_prefix.len = strlen(db_prefix.s);
408 LM_DBG("using CacheDB url: %s\n", db_url_escape(&db_url));
409 }
410
411 RL_SHM_MALLOC(rl_network_count, sizeof(int));
412 RL_SHM_MALLOC(rl_network_load, sizeof(int));
413 RL_SHM_MALLOC(rl_load_value, sizeof(double));
414 RL_SHM_MALLOC(pid_kp, sizeof(double));
415 RL_SHM_MALLOC(pid_ki, sizeof(double));
416 RL_SHM_MALLOC(pid_kd, sizeof(double));
417 RL_SHM_MALLOC(pid_setpoint, sizeof(double));
418 RL_SHM_MALLOC(drop_rate, sizeof(int));
419 RL_SHM_MALLOC(rl_feedback_limit, sizeof(int));
420
421 /* init ki value for feedback algo */
422 *pid_ki = -25.0;
423
424 rl_lock = lock_alloc();
425 if (!rl_lock) {
426 LM_ERR("cannot alloc lock\n");
427 return -1;
428 }
429
430 if (!lock_init(rl_lock)) {
431 LM_ERR("failed to init lock\n");
432 return -1;
433 }
434
435 _rl_repl_timer_expire = rl_repl_timer_expire;
436
437 /* register timer to reset counters */

Callers

nothing calls this directly

Calls 6

load_clusterer_apiFunction · 0.85
db_url_escapeFunction · 0.85
lock_initFunction · 0.85
register_utimerFunction · 0.85
init_rl_tableFunction · 0.85
rl_repl_initFunction · 0.85

Tested by

no test coverage detected