提交 476ca4b9 编写于 作者: S Shengliang Guan

delete created shms

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