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

Function reload_routing_script

cfg_reload.c:401–556  ·  view source on GitHub ↗

This is the trigger point for script reloading */

Source from the content-addressed store, hash-verified

399/* This is the trigger point for script reloading
400 */
401int reload_routing_script(void)
402{
403 struct os_script_routes *sr, *sr_bk;
404 char * curr_wdir=NULL;
405 str cfg_buf={NULL,0};
406 int cnt_sleep, ret;
407
408 /* one reload at a time */
409 lock_get( &srr_ctx->lock );
410 if (srr_ctx->seq_no!=0) {
411 LM_INFO("Reload already in progress, cannot start a new one\n");
412 lock_release( &srr_ctx->lock );
413 return -1;
414 }
415 srr_ctx->seq_no = srr_ctx->next_seq_no++;
416 lock_release( &srr_ctx->lock );
417
418 sr = new_sroutes_holder( 0 );
419 if (sr==NULL) {
420 LM_ERR("failed to allocate a new script routes holder\n");
421 goto error;
422 }
423
424 LM_INFO("reparsing routes from <%s> file\n",cfg_file);
425
426 sr_bk = sroutes;
427 sroutes = sr;
428
429 /* parse, but only the routes */
430 cfg_parse_only_routes = 1;
431
432 /* switch to the startup working dir, to be sure the file pathname
433 * (as given at startup via cli) still match */
434 if (startup_wdir) {
435 if ( (curr_wdir=getcwd(NULL,0))==NULL) {
436 LM_ERR("failed to determin the working dir %d/%s\n", errno,
437 strerror(errno));
438 goto error;
439 }
440 if (chdir(startup_wdir)<0){
441 LM_CRIT("Cannot chdir to %s: %s\n", startup_wdir, strerror(errno));
442 goto error;
443 }
444 }
445
446 ret = parse_opensips_cfg( cfg_file, preproc, &cfg_buf);
447
448 cfg_parse_only_routes = 0;
449
450 /* revert to the original working dir */
451 if (curr_wdir) {
452 if (chdir(curr_wdir)<0){
453 LM_CRIT("Cannot chdir to %s: %s\n", curr_wdir, strerror(errno));
454 }
455 free(curr_wdir);
456 curr_wdir=NULL;
457 }
458

Callers 1

w_reload_routesFunction · 0.85

Calls 13

lock_getFunction · 0.85
lock_releaseFunction · 0.85
new_sroutes_holderFunction · 0.85
parse_opensips_cfgFunction · 0.85
fix_rlsFunction · 0.85
modules_validate_reloadFunction · 0.85
free_route_listsFunction · 0.85
shm_nt_str_dupFunction · 0.85
send_cmd_to_all_procsFunction · 0.85
list_status_of_all_procsFunction · 0.85
register_route_timersFunction · 0.85

Tested by

no test coverage detected