diff --git a/source/os/src/osShm.c b/source/os/src/osShm.c index 35aec30f3921e2e50b51fd3cb84860e5dfb4a3b4..3b75e33d7c6a583b1d6a9bb04f9b55a0e84fd8f9 100644 --- a/source/os/src/osShm.c +++ b/source/os/src/osShm.c @@ -17,14 +17,27 @@ #define _DEFAULT_SOURCE #include "os.h" +#define MAX_SHMIDS 6 + +static int32_t shmids[MAX_SHMIDS] = {0}; + +static void taosDeleteCreatedShms() { + for (int32_t i = 0; i < MAX_SHMIDS; ++i) { + int32_t shmid = shmids[i] - 1; + if (shmid >= 0) { + shmctl(shmid, IPC_RMID, NULL); + } + } +} + int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) { pShm->id = -1; - // key_t shkey = IPC_PRIVATE; - // int32_t __shmflag = IPC_CREAT | IPC_EXCL | 0600; + key_t __shkey = IPC_PRIVATE; + int32_t __shmflag = IPC_CREAT | IPC_EXCL | 0600; - key_t __shkey = 0X95270000 + key; - int32_t __shmflag = IPC_CREAT | 0600; + // key_t __shkey = 0X95270000 + key; + // int32_t __shmflag = IPC_CREAT | 0600; int32_t shmid = shmget(__shkey, shmsize, __shmflag); if (shmid < 0) { @@ -39,6 +52,12 @@ int32_t taosCreateShm(SShm* pShm, int32_t key, int32_t shmsize) { pShm->id = shmid; pShm->size = shmsize; pShm->ptr = shmptr; + + if (key >= 0 && key < MAX_SHMIDS) { + shmids[key] = pShm->id + 1; + } + atexit(taosDeleteCreatedShms); + return 0; } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 4e04543fd8ab0b0b8712cd1a97cda969b10ed1fd..5a3ee003f095340db873b4a7b9c9b7ab5f3242f7 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -55,8 +55,8 @@ # --- for multi process mode -# ./test.sh -f tsim/user/basic1.sim -m -# ./test.sh -f tsim/stable/vnode3.sim -m -# ./test.sh -f tsim/tmq/basic.sim -m +./test.sh -f tsim/user/basic1.sim -m +./test.sh -f tsim/stable/vnode3.sim -m +./test.sh -f tsim/tmq/basic.sim -m #======================b1-end===============