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

Function start_module_procs

sr_module.c:887–964  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885
886
887int start_module_procs(void)
888{
889 struct sr_module *m;
890 unsigned int n;
891 unsigned int l;
892 unsigned int flags;
893 int x;
894
895 for( m=modules ; m ; m=m->next) {
896 if (m->exports->procs==NULL)
897 continue;
898 for( n=0 ; m->exports->procs[n].name ; n++) {
899 if ( !m->exports->procs[n].no || !m->exports->procs[n].function )
900 continue;
901 /* run pre-fork function */
902 if (m->exports->procs[n].pre_fork_function)
903 if (m->exports->procs[n].pre_fork_function()!=0) {
904 LM_ERR("pre-fork function failed for process \"%s\" "
905 "in module %s\n",
906 m->exports->procs[n].name, m->exports->name);
907 return -1;
908 }
909 /* fork the processes */
910 for ( l=0; l<m->exports->procs[n].no ; l++) {
911 LM_DBG("forking process \"%s\"/%d for module %s\n",
912 m->exports->procs[n].name, l, m->exports->name);
913 /* conver the module proc flags to internal proc flgas
914 * NOTE that the PROC_FLAG_NEEDS_SCRIPT automatically
915 * assumes PROC_FLAG_HAS_IPC - IPC is needed for script
916 * reload */
917 flags = OSS_PROC_IS_EXTRA;
918 if (m->exports->procs[n].flags&PROC_FLAG_NEEDS_SCRIPT)
919 flags |= OSS_PROC_NEEDS_SCRIPT;
920 if ( (m->exports->procs[n].flags&PROC_FLAG_HAS_IPC)==0)
921 flags |= OSS_PROC_NO_IPC;
922 struct internal_fork_params ifp = {
923 .proc_desc = m->exports->procs[n].name,
924 .flags = flags,
925 .type = TYPE_MODULE,
926 };
927 x = internal_fork(&ifp);
928 if (x<0) {
929 LM_ERR("failed to fork process \"%s\"/%d for module %s\n",
930 m->exports->procs[n].name, l, m->exports->name);
931 return -1;
932 } else if (x==0) {
933 /* new process */
934 /* initialize the process for the rest of the modules */
935 if ( m->exports->procs[n].flags&PROC_FLAG_INITCHILD ) {
936 if (init_child(PROC_MODULE) < 0) {
937 LM_ERR("error in init_child for PROC_MODULE\n");
938 report_failure_status();
939 exit(-1);
940 }
941
942 report_conditional_status( (!no_daemon_mode), 0);
943 } else
944 clean_write_pipeend();

Callers 1

main_loopFunction · 0.85

Calls 3

internal_forkFunction · 0.85
init_childFunction · 0.85
clean_write_pipeendFunction · 0.85

Tested by

no test coverage detected