diff --git a/source/dnode/mgmt/main/exe/dndMain.c b/source/dnode/mgmt/main/exe/dndMain.c index 0d2ddbfbbc3f55268e4e3fa1d9263ec70ae3f03f..c6a109d62a547ccd6e17aee264ccd4eaf01ac6fd 100644 --- a/source/dnode/mgmt/main/exe/dndMain.c +++ b/source/dnode/mgmt/main/exe/dndMain.c @@ -30,7 +30,6 @@ static struct { } global = {0}; static void dndStopDnode(int signum, void *info, void *ctx) { - dInfo("system signal:%d received", signum); SDnode *pDnode = atomic_val_compare_exchange_ptr(&global.pDnode, 0, global.pDnode); if (pDnode != NULL) { dndHandleEvent(pDnode, DND_EVENT_STOP); @@ -41,8 +40,10 @@ static void dndSetSignalHandle() { taosSetSignal(SIGTERM, dndStopDnode); taosSetSignal(SIGHUP, dndStopDnode); taosSetSignal(SIGINT, dndStopDnode); + taosSetSignal(SIGTSTP, dndStopDnode); taosSetSignal(SIGABRT, dndStopDnode); taosSetSignal(SIGBREAK, dndStopDnode); + taosSetSignal(SIGQUIT, dndStopDnode); if (!tsMultiProcess) { } else if (global.ntype == DNODE || global.ntype == NODE_MAX) { @@ -72,7 +73,7 @@ static int32_t dndParseArgs(int32_t argc, char const *argv[]) { } else if (strcmp(argv[i], "-n") == 0) { global.ntype = atoi(argv[++i]); if (global.ntype <= DNODE || global.ntype > NODE_MAX) { - printf("'-n' range is [1-5], default is 0\n"); + printf("'-n' range is [1 - %d], default is 0\n", NODE_MAX - 1); return -1; } } else if (strcmp(argv[i], "-k") == 0) { diff --git a/source/dnode/mgmt/main/src/dndExec.c b/source/dnode/mgmt/main/src/dndExec.c index 0cc429c0d96eb12e3fb060772e1d31d67c7027dd..281bc752ca4f92c132e6d57c17a4998d4b02c388 100644 --- a/source/dnode/mgmt/main/src/dndExec.c +++ b/source/dnode/mgmt/main/src/dndExec.c @@ -180,6 +180,7 @@ static int32_t dndRunInSingleProcess(SDnode *pDnode) { while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); + dndSetStatus(pDnode, DND_STAT_STOPPED); break; } taosMsleep(100); @@ -255,14 +256,16 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); + dndSetStatus(pDnode, DND_STAT_STOPPED); + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; if (!pWrapper->required) continue; if (pDnode->ntype == NODE_MAX) continue; if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { - // dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId); - // taosKillProc(pWrapper->procId); + dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId); + taosKillProc(pWrapper->procId); dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId); taosWaitProc(pWrapper->procId); dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId); @@ -332,10 +335,13 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("%s is about to stop", pWrapper->name); + dndSetStatus(pDnode, DND_STAT_STOPPED); break; } taosMsleep(100); } + + return 0; } int32_t dndRun(SDnode *pDnode) { diff --git a/source/dnode/mgmt/main/src/dndInt.c b/source/dnode/mgmt/main/src/dndInt.c index 602ebc6b3cfcfa2177b511bd48b49ba68272ceca..6f6e21b983d0b41f4e8765b996a6ffd4dcf9f5bf 100644 --- a/source/dnode/mgmt/main/src/dndInt.c +++ b/source/dnode/mgmt/main/src/dndInt.c @@ -133,14 +133,6 @@ _OVER: void dndClose(SDnode *pDnode) { if (pDnode == NULL) return; - if (dndGetStatus(pDnode) == DND_STAT_STOPPED) { - dError("dnode is shutting down, data:%p", pDnode); - return; - } - - dInfo("start to close dnode, data:%p", pDnode); - dndSetStatus(pDnode, DND_STAT_STOPPED); - for (ENodeType n = 0; n < NODE_MAX; ++n) { SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; dndCloseNode(pWrapper); @@ -151,7 +143,6 @@ void dndClose(SDnode *pDnode) { } void dndHandleEvent(SDnode *pDnode, EDndEvent event) { - dInfo("dnode receive %s event, data:%p", dndEventStr(event), pDnode); if (event == DND_EVENT_STOP) { pDnode->event = event; } diff --git a/source/os/src/osSignal.c b/source/os/src/osSignal.c index d4e6cb3318f788e1173c1f25192c59d731e76f37..1d7fa517e58c873a4fbfb1d66792a971945370a6 100644 --- a/source/os/src/osSignal.c +++ b/source/os/src/osSignal.c @@ -59,7 +59,7 @@ void taosSetSignal(int32_t signum, FSignalHandler sigfp) { struct sigaction act; memset(&act, 0, sizeof(act)); #if 1 - act.sa_flags = SA_SIGINFO; + act.sa_flags = SA_SIGINFO | SA_RESTART; act.sa_sigaction = (FLinuxSignalHandler)sigfp; #else act.sa_handler = sigfp;