]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
charon-svc: Check if daemon has been initialized before invoking shutdown alert
authorMartin Willi <martin@revosec.ch>
Wed, 28 May 2014 13:55:34 +0000 (15:55 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:53:12 +0000 (15:53 +0200)
src/charon-svc/charon-svc.c

index c21fc1ff55efef6cd4731cdce960e6cac439cfa7..d4fc83c48b44e7bc25b3384205d25670bc02d329 100644 (file)
@@ -170,7 +170,11 @@ static BOOL console_handler(DWORD dwCtrlType)
                case CTRL_BREAK_EVENT:
                case CTRL_CLOSE_EVENT:
                        DBG1(DBG_DMN, "application is stopping, cleaning up");
-                       charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, dwCtrlType);
+                       if (status.dwCurrentState == SERVICE_RUNNING)
+                       {
+                               charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL,
+                                                                  dwCtrlType);
+                       }
                        /* signal main thread to clean up */
                        SetEvent(event);
                        return TRUE;
@@ -204,7 +208,11 @@ static DWORD service_handler(DWORD dwControl, DWORD dwEventType,
                case SERVICE_CONTROL_STOP:
                case SERVICE_CONTROL_SHUTDOWN:
                        DBG1(DBG_DMN, "service is stopping, cleaning up");
-                       charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, dwControl);
+                       if (status.dwCurrentState == SERVICE_RUNNING)
+                       {
+                               charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL,
+                                                                  dwControl);
+                       }
                        /* signal main thread to clean up */
                        SetEvent(event);
                        return NO_ERROR;