]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
core: Fix handling of restart from remote console.
authorCorey Farrell <git@cfware.com>
Thu, 15 Nov 2018 11:25:46 +0000 (06:25 -0500)
committerCorey Farrell <git@cfware.com>
Thu, 15 Nov 2018 11:27:51 +0000 (06:27 -0500)
We cannot use need_el_end and SIGURG when restarting.  Instead we need
to run el_end within the SIGHUP restartnow handler.

ASTERISK-28158

Change-Id: Ia852276363c81bdcf1aa29eb4558c5c2fa1218a0

main/asterisk.c

index 174f9f7bf5ce0e44f78d7380d344df7b866f4cc6..edb3a22da6c44a6d695bd962b9c45965782394e7 100644 (file)
@@ -1791,10 +1791,17 @@ static struct sigaction urg_handler = {
 
 static void _hup_handler(int num)
 {
-       int a = 0, save_errno = errno;
-       printf("Received HUP signal -- Reloading configs\n");
-       if (restartnow)
+       int a = 0;
+       int save_errno = errno;
+
+       if (restartnow) {
+               if (el) {
+                       el_end(el);
+               }
                execvp(_argv[0], _argv);
+       }
+
+       printf("Received HUP signal -- Reloading configs\n");
        sig_flags.need_reload = 1;
        if (sig_alert_pipe[1] != -1) {
                if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
@@ -2137,7 +2144,7 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
                        if (el_hist != NULL) {
                                history_end(el_hist);
                        }
-               } else {
+               } else if (!restart) {
                        sig_flags.need_el_end = 1;
                        pthread_kill(consolethread, SIGURG);
                }