]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
modified switch.c to not create PID file until all modules are loaded
authorMoises Silva <moy@sangoma.com>
Mon, 30 May 2011 22:49:15 +0000 (18:49 -0400)
committerMoises Silva <moy@sangoma.com>
Mon, 30 May 2011 22:53:24 +0000 (18:53 -0400)
this help init scripts to check when everything is really loaded.
Also return 1 when loading modules fails, do not return 255 which can
be confused with a segmentation fault or some other more violent code

src/switch.c

index 7e81ab01cfc08256d093d1ad6eda5e94965bd202..fcc367c8c8c5899dbace596aa0cdf2086e44433b 100644 (file)
@@ -894,6 +894,11 @@ int main(int argc, char *argv[])
 
        switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, pool);
 
+       if (switch_core_init_and_modload(flags, nc ? SWITCH_FALSE : SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
+               fprintf(stderr, "Failed to initialize modules: %s\n", err);
+               return 1;
+       }
+
        if (switch_file_open(&fd, pid_path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) == SWITCH_STATUS_SUCCESS) {
 
                old_pid_len = sizeof(old_pid_buffer);
@@ -920,11 +925,6 @@ int main(int argc, char *argv[])
 
        switch_file_write(fd, pid_buffer, &pid_len);
 
-       if (switch_core_init_and_modload(flags, nc ? SWITCH_FALSE : SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
-               fprintf(stderr, "Cannot Initialize [%s]\n", err);
-               return 255;
-       }
-
 #ifndef WIN32
        if (do_wait) {
                kill(getppid(), SIGUSR2);