check null in signal handler
This commit is contained in:
+10
-2
@@ -650,11 +650,11 @@ void closePidFile() {
|
|||||||
*/
|
*/
|
||||||
void shutdown() {
|
void shutdown() {
|
||||||
// stop main loop and all dependent components
|
// stop main loop and all dependent components
|
||||||
if (s_mainLoop != NULL) {
|
if (s_mainLoop) {
|
||||||
delete s_mainLoop;
|
delete s_mainLoop;
|
||||||
s_mainLoop = NULL;
|
s_mainLoop = NULL;
|
||||||
}
|
}
|
||||||
if (s_messageMap != NULL) {
|
if (s_messageMap) {
|
||||||
delete s_messageMap;
|
delete s_messageMap;
|
||||||
s_messageMap = NULL;
|
s_messageMap = NULL;
|
||||||
}
|
}
|
||||||
@@ -695,11 +695,19 @@ void signalHandler(int sig) {
|
|||||||
break;
|
break;
|
||||||
case SIGINT:
|
case SIGINT:
|
||||||
logNotice(lf_main, "SIGINT received");
|
logNotice(lf_main, "SIGINT received");
|
||||||
|
if (s_mainLoop) {
|
||||||
s_mainLoop->shutdown();
|
s_mainLoop->shutdown();
|
||||||
|
} else {
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
logNotice(lf_main, "SIGTERM received");
|
logNotice(lf_main, "SIGTERM received");
|
||||||
|
if (s_mainLoop) {
|
||||||
s_mainLoop->shutdown();
|
s_mainLoop->shutdown();
|
||||||
|
} else {
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logNotice(lf_main, "undefined signal %s", strsignal(sig));
|
logNotice(lf_main, "undefined signal %s", strsignal(sig));
|
||||||
|
|||||||
Reference in New Issue
Block a user