Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
474939ee
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
474939ee
编写于
3月 25, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shm
上级
1436d2f2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
38 addition
and
41 deletion
+38
-41
source/dnode/mgmt/container/src/dndExec.c
source/dnode/mgmt/container/src/dndExec.c
+0
-1
source/util/src/tprocess.c
source/util/src/tprocess.c
+38
-40
未找到文件。
source/dnode/mgmt/container/src/dndExec.c
浏览文件 @
474939ee
...
...
@@ -178,7 +178,6 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
.
parentFreeHeadFp
=
(
ProcFreeFp
)
free
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
testFlag
=
0
,
.
pParent
=
pWrapper
,
.
name
=
pWrapper
->
name
};
SProcObj
*
pProc
=
taosProcInit
(
&
cfg
);
...
...
source/util/src/tprocess.c
浏览文件 @
474939ee
...
...
@@ -56,7 +56,6 @@ typedef struct SProcObj {
int32_t
pid
;
bool
isChild
;
bool
stopFlag
;
bool
testFlag
;
}
SProcObj
;
static
int32_t
taosProcInitMutex
(
TdThreadMutex
**
ppMutex
,
int32_t
*
pShmid
)
{
...
...
@@ -77,7 +76,7 @@ static int32_t taosProcInitMutex(TdThreadMutex **ppMutex, int32_t *pShmid) {
goto
_OVER
;
}
shmid
=
shmget
(
IPC_PRIVATE
,
sizeof
(
TdThreadMutex
),
0600
);
shmid
=
shmget
(
IPC_PRIVATE
,
sizeof
(
TdThreadMutex
),
IPC_CREAT
|
0600
);
if
(
shmid
<=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to init mutex while shmget since %s"
,
terrstr
());
...
...
@@ -101,8 +100,13 @@ static int32_t taosProcInitMutex(TdThreadMutex **ppMutex, int32_t *pShmid) {
_OVER:
if
(
code
!=
0
)
{
taosThreadMutexDestroy
(
pMutex
);
shmctl
(
shmid
,
IPC_RMID
,
NULL
);
if
(
pMutex
!=
NULL
)
{
taosThreadMutexDestroy
(
pMutex
);
shmdt
(
pMutex
);
}
if
(
shmid
>=
0
)
{
shmctl
(
shmid
,
IPC_RMID
,
NULL
);
}
}
else
{
*
ppMutex
=
pMutex
;
*
pShmid
=
shmid
;
...
...
@@ -112,12 +116,12 @@ _OVER:
return
code
;
}
static
void
taosProcDestroyMutex
(
TdThreadMutex
*
pMutex
,
int32_t
*
pS
hmid
)
{
static
void
taosProcDestroyMutex
(
TdThreadMutex
*
pMutex
,
int32_t
s
hmid
)
{
if
(
pMutex
!=
NULL
)
{
taosThreadMutexDestroy
(
pMutex
);
}
if
(
*
pShmid
>
0
)
{
shmctl
(
*
pS
hmid
,
IPC_RMID
,
NULL
);
if
(
shmid
>=
0
)
{
shmctl
(
s
hmid
,
IPC_RMID
,
NULL
);
}
}
...
...
@@ -141,9 +145,10 @@ static int32_t taosProcInitBuffer(void **ppBuffer, int32_t size) {
return
shmid
;
}
static
void
taosProcDestroyBuffer
(
void
*
pBuffer
,
int32_t
*
pShmid
)
{
if
(
*
pShmid
>
0
)
{
shmctl
(
*
pShmid
,
IPC_RMID
,
NULL
);
static
void
taosProcDestroyBuffer
(
void
*
pBuffer
,
int32_t
shmid
)
{
if
(
shmid
>
0
)
{
shmdt
(
pBuffer
);
shmctl
(
shmid
,
IPC_RMID
,
NULL
);
}
}
...
...
@@ -155,29 +160,28 @@ static SProcQueue *taosProcQueueInit(int32_t size) {
SProcQueue
*
pQueue
=
NULL
;
int32_t
shmId
=
taosProcInitBuffer
((
void
**
)
&
pQueue
,
bufSize
+
headSize
);
if
(
shmId
<
=
0
)
{
if
(
shmId
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
pQueue
->
bufferShmid
=
shmId
;
if
(
taosProcInitMutex
(
&
pQueue
->
mutex
,
&
pQueue
->
mutexShmid
)
!=
0
)
{
free
(
pQueue
);
taosProcDestroyBuffer
(
pQueue
,
pQueue
->
bufferShmid
);
return
NULL
;
}
if
(
tsem_init
(
&
pQueue
->
sem
,
1
,
0
)
!=
0
)
{
taosProcDestroyMutex
(
pQueue
->
mutex
,
&
pQueue
->
mutexShmid
);
free
(
pQueue
);
taosProcDestroyMutex
(
pQueue
->
mutex
,
pQueue
->
mutexShmid
);
taosProcDestroyBuffer
(
pQueue
,
pQueue
->
bufferShmid
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
if
(
taosProcInitMutex
(
&
pQueue
->
mutex
,
&
pQueue
->
mutexShmid
)
!=
0
)
{
taosProcDestroyMutex
(
pQueue
->
mutex
,
&
pQueue
->
mutexShmid
);
tsem_destroy
(
&
pQueue
->
sem
);
free
(
pQueue
);
taosProcDestroyMutex
(
pQueue
->
mutex
,
pQueue
->
mutexShmid
);
taosProcDestroyBuffer
(
pQueue
,
pQueue
->
bufferShmid
);
return
NULL
;
}
...
...
@@ -190,12 +194,12 @@ static SProcQueue *taosProcQueueInit(int32_t size) {
return
pQueue
;
}
static
void
taosProc
QueueCleanup
(
SProcQueue
*
pQueue
)
{
static
void
taosProc
CleanupQueue
(
SProcQueue
*
pQueue
)
{
if
(
pQueue
!=
NULL
)
{
uDebug
(
"proc:%s, queue:%p clean up"
,
pQueue
->
name
,
pQueue
);
taosProcDestroyMutex
(
pQueue
->
mutex
,
&
pQueue
->
mutexShmid
);
tsem_destroy
(
&
pQueue
->
sem
);
free
(
pQueue
);
taosProcDestroyMutex
(
pQueue
->
mutex
,
pQueue
->
mutexShmid
);
taosProcDestroyBuffer
(
pQueue
,
pQueue
->
bufferShmid
);
}
}
...
...
@@ -344,12 +348,10 @@ SProcObj *taosProcInit(const SProcCfg *pCfg) {
}
pProc
->
name
=
pCfg
->
name
;
pProc
->
testFlag
=
pCfg
->
testFlag
;
pProc
->
pChildQueue
=
taosProcQueueInit
(
pCfg
->
childQueueSize
);
pProc
->
pParentQueue
=
taosProcQueueInit
(
pCfg
->
parentQueueSize
);
if
(
pProc
->
pChildQueue
==
NULL
||
pProc
->
pParentQueue
==
NULL
)
{
taosProc
QueueCleanup
(
pProc
->
pChildQueue
);
taosProc
CleanupQueue
(
pProc
->
pChildQueue
);
free
(
pProc
);
return
NULL
;
}
...
...
@@ -369,17 +371,15 @@ SProcObj *taosProcInit(const SProcCfg *pCfg) {
pProc
->
pParentQueue
->
freeBodyFp
=
pCfg
->
parentFreeBodyFp
;
pProc
->
pParentQueue
->
consumeFp
=
pCfg
->
parentConsumeFp
;
uDebug
(
"proc:%s, initialized, child queue:%p parent queue:%p"
,
pProc
->
name
,
pProc
->
pChildQueue
,
pProc
->
pParentQueue
);
uDebug
(
"proc:%s, i
s i
nitialized, child queue:%p parent queue:%p"
,
pProc
->
name
,
pProc
->
pChildQueue
,
pProc
->
pParentQueue
);
if
(
!
pProc
->
testFlag
)
{
pProc
->
pid
=
fork
();
if
(
pProc
->
pid
==
0
)
{
pProc
->
isChild
=
1
;
uInfo
(
"this is child process, pid:%d"
,
pProc
->
pid
);
}
else
{
pProc
->
isChild
=
0
;
uInfo
(
"this is parent process, pid:%d"
,
pProc
->
pid
);
}
pProc
->
pid
=
fork
();
if
(
pProc
->
pid
==
0
)
{
pProc
->
isChild
=
1
;
uInfo
(
"this is child process, pid:%d"
,
pProc
->
pid
);
}
else
{
pProc
->
isChild
=
0
;
uInfo
(
"this is parent process, child pid:%d"
,
pProc
->
pid
);
}
return
pProc
;
...
...
@@ -398,7 +398,7 @@ static void taosProcThreadLoop(SProcQueue *pQueue) {
if
(
code
<
0
)
{
uDebug
(
"proc:%s, get no message from queue:%p and exiting"
,
pQueue
->
name
,
pQueue
);
break
;
}
else
if
(
code
<
0
)
{
}
else
if
(
code
==
0
)
{
uTrace
(
"proc:%s, get no message from queue:%p since %s"
,
pQueue
->
name
,
pQueue
,
terrstr
());
taosMsleep
(
1
);
continue
;
...
...
@@ -413,16 +413,14 @@ int32_t taosProcRun(SProcObj *pProc) {
taosThreadAttrInit
(
&
thAttr
);
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
if
(
pProc
->
isChild
||
pProc
->
testFlag
)
{
if
(
pProc
->
isChild
)
{
if
(
taosThreadCreate
(
&
pProc
->
childThread
,
&
thAttr
,
(
ProcThreadFp
)
taosProcThreadLoop
,
pProc
->
pChildQueue
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to create thread since %s"
,
terrstr
());
return
-
1
;
}
uDebug
(
"proc:%s, child start to consume queue:%p"
,
pProc
->
name
,
pProc
->
pChildQueue
);
}
if
(
!
pProc
->
isChild
||
pProc
->
testFlag
)
{
}
else
{
if
(
taosThreadCreate
(
&
pProc
->
parentThread
,
&
thAttr
,
(
ProcThreadFp
)
taosProcThreadLoop
,
pProc
->
pParentQueue
)
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
uError
(
"failed to create thread since %s"
,
terrstr
());
...
...
@@ -445,8 +443,8 @@ void taosProcCleanup(SProcObj *pProc) {
if
(
pProc
!=
NULL
)
{
uDebug
(
"proc:%s, clean up"
,
pProc
->
name
);
taosProcStop
(
pProc
);
taosProc
QueueCleanup
(
pProc
->
pChildQueue
);
taosProc
QueueCleanup
(
pProc
->
pParentQueue
);
taosProc
CleanupQueue
(
pProc
->
pChildQueue
);
taosProc
CleanupQueue
(
pProc
->
pParentQueue
);
free
(
pProc
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录