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

Function main_loop

main.c:248–378  ·  view source on GitHub ↗

* Main loop, forks the children, bind to addresses, * handle signals. * \return don't return on sucess, -1 on error */

Source from the content-addressed store, hash-verified

246 * \return don't return on sucess, -1 on error
247 */
248static int main_loop(void)
249{
250 static int chd_rank;
251 int* startup_done = NULL;
252 utime_t last_check = 0;
253 int rc;
254 static struct internal_fork_handler profiling_handler = {
255 .desc = "_ProfilerStart_child()",
256 .post_fork.in_child = _ProfilerStart_child,
257 .post_fork.in_parent = _ProfilerStart_parent,
258 };
259
260 chd_rank=0;
261 register_fork_handler(&profiling_handler);
262
263 if (start_module_procs()!=0) {
264 LM_ERR("failed to fork module processes\n");
265 goto error;
266 }
267
268 if(sroutes->startup.a) {/* if a startup route was defined */
269 startup_done = (int*)shm_malloc(sizeof(int));
270 if(startup_done == NULL) {
271 LM_ERR("No more shared memory\n");
272 goto error;
273 }
274 *startup_done = 0;
275 }
276
277 /* fork for the timer process*/
278 if (start_timer_processes()!=0) {
279 LM_CRIT("cannot start timer process(es)\n");
280 goto error;
281 }
282
283 /* fork all processes required by UDP network layer */
284 if (udp_start_processes( &chd_rank, startup_done)<0) {
285 LM_CRIT("cannot start UDP processes\n");
286 goto error;
287 }
288
289 /* fork all processes required by TCP network layer */
290 if (tcp_start_processes( &chd_rank, startup_done)<0) {
291 LM_CRIT("cannot start TCP processes\n");
292 goto error;
293 }
294
295 /* fork for the extra timer processes */
296 if (start_timer_extra_processes( &chd_rank )!=0) {
297 LM_CRIT("cannot start timer extra process(es)\n");
298 goto error;
299 }
300
301 /* fork the TCP listening process */
302 if (tcp_start_listener()<0) {
303 LM_CRIT("cannot start TCP listener process\n");
304 goto error;
305 }

Callers 1

mainFunction · 0.85

Calls 15

register_fork_handlerFunction · 0.85
start_module_procsFunction · 0.85
shm_mallocFunction · 0.85
start_timer_processesFunction · 0.85
udp_start_processesFunction · 0.85
tcp_start_processesFunction · 0.85
tcp_start_listenerFunction · 0.85
shm_freeFunction · 0.85
sr_set_core_statusFunction · 0.85
sr_add_core_reportFunction · 0.85
set_proc_attrsFunction · 0.85

Tested by

no test coverage detected