提交 e1660a12 编写于 作者: S Shengliang Guan

shm

上级 c3917c25
......@@ -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) {
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册