Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
efbc3fc7
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
efbc3fc7
编写于
5月 19, 2023
作者:
D
dapan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: tmr in windows can't re-init issue
上级
a61f0533
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
40 addition
and
10 deletion
+40
-10
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+1
-0
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+2
-0
source/util/src/ttimer.c
source/util/src/ttimer.c
+37
-10
未找到文件。
source/libs/catalog/src/catalog.c
浏览文件 @
efbc3fc7
...
...
@@ -716,6 +716,7 @@ int32_t ctgGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
qDebug
(
"catalogInit start"
);
if
(
gCtgMgmt
.
pCluster
)
{
qError
(
"catalog already initialized"
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
efbc3fc7
...
...
@@ -37,6 +37,7 @@
#include "tglobal.h"
#include "trpc.h"
#include "tvariant.h"
#include "ttimer.h"
namespace
{
...
...
@@ -150,6 +151,7 @@ void ctgTestInitLogFile() {
tsAsyncLog
=
0
;
qDebugFlag
=
159
;
tmrDebugFlag
=
159
;
strcpy
(
tsLogDir
,
TD_LOG_DIR_PATH
);
ctgdEnableDebug
(
"api"
,
true
);
...
...
source/util/src/ttimer.c
浏览文件 @
efbc3fc7
...
...
@@ -113,7 +113,7 @@ typedef struct time_wheel_t {
static
int32_t
tsMaxTmrCtrl
=
TSDB_MAX_VNODES_PER_DB
+
100
;
static
TdThreadOnce
tmrModuleInit
=
PTHREAD_ONCE_INIT
;
static
int32_t
tmrModuleInit
=
0
;
static
TdThreadMutex
tmrCtrlMutex
;
static
tmr_ctrl_t
*
tmrCtrls
;
static
tmr_ctrl_t
*
unusedTmrCtrl
=
NULL
;
...
...
@@ -512,11 +512,11 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* han
return
stopped
;
}
static
void
taosTmrModuleInit
(
void
)
{
static
int32_t
taosTmrModuleInit
(
void
)
{
tmrCtrls
=
taosMemoryMalloc
(
sizeof
(
tmr_ctrl_t
)
*
tsMaxTmrCtrl
);
if
(
tmrCtrls
==
NULL
)
{
tmrError
(
"failed to allocate memory for timer controllers."
);
return
;
return
-
1
;
}
memset
(
&
timerMap
,
0
,
sizeof
(
timerMap
));
...
...
@@ -535,14 +535,14 @@ static void taosTmrModuleInit(void) {
time_wheel_t
*
wheel
=
wheels
+
i
;
if
(
taosThreadMutexInit
(
&
wheel
->
mutex
,
NULL
)
!=
0
)
{
tmrError
(
"failed to create the mutex for wheel, reason:%s"
,
strerror
(
errno
));
return
;
return
-
1
;
}
wheel
->
nextScanAt
=
now
+
wheel
->
resolution
;
wheel
->
index
=
0
;
wheel
->
slots
=
(
tmr_obj_t
**
)
taosMemoryCalloc
(
wheel
->
size
,
sizeof
(
tmr_obj_t
*
));
if
(
wheel
->
slots
==
NULL
)
{
tmrError
(
"failed to allocate wheel slots"
);
return
;
return
-
1
;
}
timerMap
.
size
+=
wheel
->
size
;
}
...
...
@@ -551,20 +551,48 @@ static void taosTmrModuleInit(void) {
timerMap
.
slots
=
(
timer_list_t
*
)
taosMemoryCalloc
(
timerMap
.
size
,
sizeof
(
timer_list_t
));
if
(
timerMap
.
slots
==
NULL
)
{
tmrError
(
"failed to allocate hash map"
);
return
;
return
-
1
;
}
tmrQhandle
=
taosInitScheduler
(
10000
,
taosTmrThreads
,
"tmr"
,
NULL
);
taosInitTimer
(
taosTimerLoopFunc
,
MSECONDS_PER_TICK
);
tmrDebug
(
"timer module is initialized, number of threads: %d"
,
taosTmrThreads
);
return
2
;
}
static
int32_t
taosTmrInitModule
(
void
)
{
if
(
atomic_load_32
(
&
tmrModuleInit
)
==
2
)
{
return
0
;
}
if
(
atomic_load_32
(
&
tmrModuleInit
)
<
0
)
{
return
-
1
;
}
while
(
true
)
{
if
(
0
==
atomic_val_compare_exchange_32
(
&
tmrModuleInit
,
0
,
1
))
{
atomic_store_32
(
&
tmrModuleInit
,
taosTmrModuleInit
());
}
else
if
(
atomic_load_32
(
&
tmrModuleInit
)
<
0
)
{
return
-
1
;
}
else
if
(
atomic_load_32
(
&
tmrModuleInit
)
==
2
)
{
return
0
;
}
else
{
taosMsleep
(
1
);
}
}
return
-
1
;
}
void
*
taosTmrInit
(
int32_t
maxNumOfTmrs
,
int32_t
resolution
,
int32_t
longest
,
const
char
*
label
)
{
const
char
*
ret
=
taosMonotonicInit
();
tmrDebug
(
"ttimer monotonic clock source:%s"
,
ret
);
taosThreadOnce
(
&
tmrModuleInit
,
taosTmrModuleInit
);
if
(
taosTmrInitModule
()
<
0
)
{
return
NULL
;
}
taosThreadMutexLock
(
&
tmrCtrlMutex
);
tmr_ctrl_t
*
ctrl
=
unusedTmrCtrl
;
...
...
@@ -581,6 +609,7 @@ void* taosTmrInit(int32_t maxNumOfTmrs, int32_t resolution, int32_t longest, con
}
tstrncpy
(
ctrl
->
label
,
label
,
sizeof
(
ctrl
->
label
));
tmrDebug
(
"%s timer controller is initialized, number of timer controllers: %d."
,
label
,
numOfTmrCtrl
);
return
ctrl
;
}
...
...
@@ -629,8 +658,6 @@ void taosTmrCleanUp(void* handle) {
tmrCtrls
=
NULL
;
unusedTmrCtrl
=
NULL
;
#if defined(LINUX)
tmrModuleInit
=
PTHREAD_ONCE_INIT
;
// to support restart
#endif
atomic_store_32
(
&
tmrModuleInit
,
0
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录