From 13e6efe3fc17b8aa61d0bf8424507ab1df906b15 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 1 Apr 2022 15:29:13 +0800 Subject: [PATCH] shm --- include/os/osShm.h | 2 +- source/dnode/mgmt/main/src/dndExec.c | 17 ++++------------- source/os/src/osProc.c | 2 +- source/os/src/osShm.c | 4 ++-- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/os/osShm.h b/include/os/osShm.h index d26a99e277..61ffc0f6cc 100644 --- a/include/os/osShm.h +++ b/include/os/osShm.h @@ -26,7 +26,7 @@ typedef struct { void* ptr; } SShm; -int32_t taosCreateShm(SShm *pShm, int32_t shmsize) ; +int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize) ; void taosDropShm(SShm *pShm); int32_t taosAttachShm(SShm *pShm); diff --git a/source/dnode/mgmt/main/src/dndExec.c b/source/dnode/mgmt/main/src/dndExec.c index b37893aa6f..0cc429c0d9 100644 --- a/source/dnode/mgmt/main/src/dndExec.c +++ b/source/dnode/mgmt/main/src/dndExec.c @@ -202,7 +202,7 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { if (!pWrapper->required) continue; int32_t shmsize = 1024 * 1024 * 2; // size will be a configuration item - if (taosCreateShm(&pWrapper->shm, shmsize) != 0) { + if (taosCreateShm(&pWrapper->shm, n, shmsize) != 0) { terrno = TAOS_SYSTEM_ERROR(terrno); dError("node:%s, failed to create shm size:%d since %s", pWrapper->name, shmsize, terrstr()); return -1; @@ -261,17 +261,8 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { 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); - } - } - - 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, 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); @@ -340,7 +331,7 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { dndReportStartup(pDnode, "TDengine", "initialized successfully"); while (1) { if (pDnode->event == DND_EVENT_STOP) { - dInfo("dnode is about to stop"); + dInfo("%s is about to stop", pWrapper->name); break; } taosMsleep(100); diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c index 6b52fa30be..262160c033 100644 --- a/source/os/src/osProc.c +++ b/source/os/src/osProc.c @@ -33,7 +33,7 @@ int32_t taosNewProc(char **args) { } void taosWaitProc(int32_t pid) { - int32_t status = 0; + int32_t status = -1; waitpid(pid, &status, 0); } diff --git a/source/os/src/osShm.c b/source/os/src/osShm.c index ba184c1f5d..bf784f14ac 100644 --- a/source/os/src/osShm.c +++ b/source/os/src/osShm.c @@ -17,10 +17,10 @@ #define _DEFAULT_SOURCE #include "os.h" -int32_t taosCreateShm(SShm* pShm, int32_t shmsize) { +int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) { pShm->id = -1; - int32_t shmid = shmget(0X95279527, shmsize, IPC_CREAT | 0600); + int32_t shmid = shmget(0X95270000 + key, shmsize, IPC_CREAT | 0600); if (shmid < 0) { return -1; } -- GitLab