| 912 | |
| 913 | |
| 914 | int start_timer_extra_processes(int *chd_rank) |
| 915 | { |
| 916 | int i, p_id; |
| 917 | const struct internal_fork_params ifp_th = { |
| 918 | .proc_desc = "Timer handler", |
| 919 | .flags = OSS_PROC_NEEDS_SCRIPT, |
| 920 | .type = TYPE_TIMER, |
| 921 | }; |
| 922 | |
| 923 | if (auto_scaling_enabled && s_profile && |
| 924 | create_process_group( TYPE_TIMER, NULL, s_profile , |
| 925 | fork_dynamic_timer_process, timer_process_graceful_terminate)!=0) |
| 926 | LM_ERR("failed to create group of TIMER processes, " |
| 927 | "auto forking will not be possible\n"); |
| 928 | |
| 929 | for( i=0 ; i<timer_workers_no ; i++ ) { |
| 930 | |
| 931 | (*chd_rank)++; |
| 932 | if ( (p_id=internal_fork(&ifp_th))<0 ) { |
| 933 | LM_CRIT("cannot fork Timer handler process\n"); |
| 934 | return -1; |
| 935 | } else if (p_id==0) { |
| 936 | /* new Timer process */ |
| 937 | /* set a more detailed description */ |
| 938 | set_proc_attrs("Timer handler"); |
| 939 | if (timer_proc_reactor_init() < 0 || |
| 940 | init_child(*chd_rank) < 0) { |
| 941 | report_failure_status(); |
| 942 | goto error; |
| 943 | } |
| 944 | |
| 945 | report_conditional_status( (!no_daemon_mode), 0); |
| 946 | |
| 947 | /* launch the reactor */ |
| 948 | reactor_main_loop( 1/*timeout in sec*/, error , ); |
| 949 | destroy_worker_reactor(); |
| 950 | |
| 951 | exit(-1); |
| 952 | } |
| 953 | /*parent*/ |
| 954 | |
| 955 | } |
| 956 | |
| 957 | return 0; |
| 958 | |
| 959 | /* only from child process */ |
| 960 | error: |
| 961 | exit(-1); |
| 962 | } |
| 963 | |
| 964 | |
| 965 | void handle_timer_job(void) |
no test coverage detected