| 901 | } |
| 902 | |
| 903 | static int mod_init(void) |
| 904 | { |
| 905 | unsigned int timer_sets,set; |
| 906 | unsigned int roundto_init; |
| 907 | |
| 908 | LM_INFO("TM - initializing, max branches [%d], branches chunk [%d]," |
| 909 | "branch bitmask size [%d/%zu] ...\n", |
| 910 | TM_BRANCH_MAX, TM_BRANCH_CHUNK_SIZE, TM_BRANCH_MAX_FACTOR, |
| 911 | sizeof(branch_bm_t)); |
| 912 | |
| 913 | minor_branch_flag = |
| 914 | get_flag_id_by_name(FLAG_TYPE_BRANCH, minor_branch_flag_str, 0); |
| 915 | |
| 916 | if (minor_branch_flag!=-1) { |
| 917 | if (minor_branch_flag > (8*sizeof(int)-1)) { |
| 918 | LM_CRIT("invalid minor branch flag\n"); |
| 919 | return -1; |
| 920 | } |
| 921 | minor_branch_flag = 1<<minor_branch_flag; |
| 922 | } else { |
| 923 | minor_branch_flag = 0; |
| 924 | } |
| 925 | |
| 926 | /* if statistics are disabled, prevent their registration to core */ |
| 927 | if (tm_enable_stats==0) |
| 928 | #ifdef STATIC_TM |
| 929 | tm_exports.stats = 0; |
| 930 | #else |
| 931 | exports.stats = 0; |
| 932 | #endif |
| 933 | |
| 934 | if (init_callid() < 0) { |
| 935 | LM_CRIT("Error while initializing Call-ID generator\n"); |
| 936 | return -1; |
| 937 | } |
| 938 | |
| 939 | /* how many timer sets do we need to create? */ |
| 940 | timer_sets = (timer_partitions<=1)?1:timer_partitions ; |
| 941 | |
| 942 | /* try first allocating all the structures needed for syncing */ |
| 943 | if (lock_initialize( timer_sets )==-1) |
| 944 | return -1; |
| 945 | |
| 946 | /* building the hash table*/ |
| 947 | if (!init_hash_table( timer_sets )) { |
| 948 | LM_ERR("initializing hash_table failed\n"); |
| 949 | return -1; |
| 950 | } |
| 951 | |
| 952 | /* init static hidden values */ |
| 953 | init_t(); |
| 954 | |
| 955 | if (!tm_init_timers( timer_sets ) ) { |
| 956 | LM_ERR("timer init failed\n"); |
| 957 | return -1; |
| 958 | } |
| 959 | |
| 960 | /* the ROUNDTO macro taken from the locking interface */ |
nothing calls this directly
no test coverage detected