starts all UDP related processes */
| 495 | |
| 496 | /* starts all UDP related processes */ |
| 497 | int udp_start_processes(int *chd_rank, int *startup_done) |
| 498 | { |
| 499 | struct socket_info_full *sif; |
| 500 | int p_id; |
| 501 | int i,p; |
| 502 | const struct internal_fork_params ifp_udp_rcv = { |
| 503 | .proc_desc = "UDP receiver", |
| 504 | .flags = OSS_PROC_NEEDS_SCRIPT, |
| 505 | .type = TYPE_UDP, |
| 506 | }; |
| 507 | |
| 508 | if (udp_disabled) |
| 509 | return 0; |
| 510 | |
| 511 | for( p=PROTO_FIRST ; p<PROTO_LAST ; p++ ) { |
| 512 | if ( !is_udp_based_proto(p) ) |
| 513 | continue; |
| 514 | |
| 515 | for( sif=protos[p].listeners; sif ; sif=sif->next ) { |
| 516 | struct socket_info* si = &sif->socket_info; |
| 517 | |
| 518 | if ( auto_scaling_enabled && si->s_profile && |
| 519 | create_process_group( TYPE_UDP, si, si->s_profile, |
| 520 | fork_dynamic_udp_process, udp_process_graceful_terminate)!=0) |
| 521 | LM_ERR("failed to create group of UDP processes for <%.*s>, " |
| 522 | "auto forking will not be possible\n", |
| 523 | si->name.len, si->name.s); |
| 524 | |
| 525 | for (i=0;i<si->workers;i++) { |
| 526 | (*chd_rank)++; |
| 527 | if ( (p_id=internal_fork(&ifp_udp_rcv))<0 ) { |
| 528 | LM_CRIT("cannot fork UDP process\n"); |
| 529 | goto error; |
| 530 | } else if (p_id==0) { |
| 531 | /* new UDP process */ |
| 532 | /* set a more detailed description */ |
| 533 | set_proc_attrs("SIP receiver %.*s", |
| 534 | si->sock_str.len, si->sock_str.s); |
| 535 | pt[process_no].pg_filter = si; |
| 536 | bind_address=si; /* shortcut */ |
| 537 | /* we first need to init the reactor to be able to add fd |
| 538 | * into it in child_init routines */ |
| 539 | if (udp_proc_reactor_init(si) < 0 || |
| 540 | init_child(*chd_rank) < 0) { |
| 541 | report_failure_status(); |
| 542 | if (*chd_rank == 1 && startup_done) |
| 543 | *startup_done = -1; |
| 544 | exit(-1); |
| 545 | } |
| 546 | |
| 547 | /* first UDP proc runs statup_route (if defined) */ |
| 548 | if(*chd_rank == 1 && startup_done!=NULL) { |
| 549 | LM_DBG("running startup for first UDP\n"); |
| 550 | if(run_startup_route()< 0) { |
| 551 | report_failure_status(); |
| 552 | *startup_done = -1; |
| 553 | LM_ERR("Startup route processing failed\n"); |
| 554 | exit(-1); |
no test coverage detected