Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CSDN产品汪
TDengine
提交
77f1cf16
T
TDengine
项目概览
CSDN产品汪
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
77f1cf16
编写于
4月 17, 2020
作者:
S
slguan
提交者:
GitHub
4月 17, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1633 from taosdata/hotfix/timer-memory-leak
fix memory leaks in timer
上级
14acfd35
467dcc07
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
14 deletion
+35
-14
src/os/darwin/src/tdarwin.c
src/os/darwin/src/tdarwin.c
+5
-0
src/os/linux/src/tlinux.c
src/os/linux/src/tlinux.c
+8
-5
src/os/windows/src/twintimer.c
src/os/windows/src/twintimer.c
+5
-1
src/util/inc/tutil.h
src/util/inc/tutil.h
+1
-0
src/util/src/ttimer.c
src/util/src/ttimer.c
+16
-8
未找到文件。
src/os/darwin/src/tdarwin.c
浏览文件 @
77f1cf16
...
...
@@ -243,6 +243,11 @@ int taosInitTimer(void (*callback)(int), int ms) {
return
setitimer
(
ITIMER_REAL
,
&
tv
,
NULL
);
}
void
taosUninitTimer
()
{
struct
itimerval
tv
=
{
0
};
return
setitimer
(
ITIMER_REAL
,
&
tv
,
NULL
);
}
void
taosGetSystemTimezone
()
{
// get and set default timezone
SGlobalConfig
*
cfg_timezone
=
tsGetConfigOption
(
"timezone"
);
...
...
src/os/linux/src/tlinux.c
浏览文件 @
77f1cf16
...
...
@@ -286,20 +286,23 @@ void *taosProcessAlarmSignal(void *tharg) {
return
NULL
;
}
static
pthread_t
timerThread
;
int
taosInitTimer
(
void
(
*
callback
)(
int
),
int
ms
)
{
pthread_t
thread
;
pthread_attr_t
tattr
;
pthread_attr_init
(
&
tattr
);
pthread_attr_setdetachstate
(
&
tattr
,
PTHREAD_CREATE_DETACHED
);
int
code
=
pthread_create
(
&
thread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
pthread_detach
(
thread
);
int
code
=
pthread_create
(
&
timerThread
,
&
tattr
,
taosProcessAlarmSignal
,
callback
);
pthread_attr_destroy
(
&
tattr
);
if
(
code
!=
0
)
{
tmrError
(
"failed to create timer thread"
);
return
-
1
;
}
return
0
;
}
return
thread
;
void
taosUninitTimer
()
{
pthread_cancel
(
timerThread
);
pthread_join
(
timerThread
,
NULL
);
}
ssize_t
tread
(
int
fd
,
void
*
buf
,
size_t
count
)
{
...
...
src/os/windows/src/twintimer.c
浏览文件 @
77f1cf16
...
...
@@ -30,8 +30,8 @@ void WINAPI taosWinOnTimer(UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR
}
}
static
MMRESULT
timerId
;
int
taosInitTimer
(
win_timer_f
callback
,
int
ms
)
{
MMRESULT
timerId
;
DWORD_PTR
param
=
*
((
int64_t
*
)
&
callback
);
timerId
=
timeSetEvent
(
ms
,
1
,
(
LPTIMECALLBACK
)
taosWinOnTimer
,
param
,
TIME_PERIODIC
);
...
...
@@ -41,6 +41,10 @@ int taosInitTimer(win_timer_f callback, int ms) {
return
0
;
}
void
taosUninitTimer
()
{
timeKillEvent
(
timerId
);
}
void
taosMsleep
(
int
mseconds
)
{
Sleep
(
mseconds
);
}
...
...
src/util/inc/tutil.h
浏览文件 @
77f1cf16
...
...
@@ -139,6 +139,7 @@ int32_t taosFileRename(char *fullPath, char *suffix, char delimiter, char **dstP
void
getTmpfilePath
(
const
char
*
fileNamePattern
,
char
*
dstPath
);
int32_t
taosInitTimer
(
void
(
*
callback
)(
int
),
int32_t
ms
);
void
taosUninitTimer
();
bool
taosMbsToUcs4
(
char
*
mbs
,
int32_t
mbs_len
,
char
*
ucs4
,
int32_t
ucs4_max_len
);
...
...
src/util/src/ttimer.c
浏览文件 @
77f1cf16
...
...
@@ -84,8 +84,6 @@ static tmr_ctrl_t* tmrCtrls;
static
tmr_ctrl_t
*
unusedTmrCtrl
=
NULL
;
static
void
*
tmrQhandle
;
static
int
numOfTmrCtrl
=
0
;
//static void* tmrContext = NULL;
static
int
athread
=
0
;
int
taosTmrThreads
=
1
;
...
...
@@ -519,7 +517,7 @@ static void taosTmrModuleInit(void) {
}
tmrQhandle
=
taosInitScheduler
(
10000
,
taosTmrThreads
,
"tmr"
);
athread
=
taosInitTimer
(
taosTimerLoopFunc
,
MSECONDS_PER_TICK
);
taosInitTimer
(
taosTimerLoopFunc
,
MSECONDS_PER_TICK
);
tmrTrace
(
"timer module is initialized, number of threads: %d"
,
taosTmrThreads
);
}
...
...
@@ -562,19 +560,29 @@ void taosTmrCleanUp(void* handle) {
pthread_mutex_unlock
(
&
tmrCtrlMutex
);
if
(
numOfTmrCtrl
<=
0
)
{
// pthread_cancel(athread
);
taosUninitTimer
(
);
taosCleanUpScheduler
(
tmrQhandle
);
for
(
int
i
=
0
;
i
<
tListLen
(
wheels
);
i
++
)
{
time_wheel_t
*
wheel
=
wheels
+
i
;
pthread_mutex_destroy
(
&
wheel
->
mutex
);
free
(
wheel
->
slots
);
}
pthread_mutex_destroy
(
&
tmrCtrlMutex
);
free
(
timerMap
.
slots
);
pthread_mutex_destroy
(
&
tmrCtrlMutex
);
for
(
size_t
i
=
0
;
i
<
timerMap
.
size
;
i
++
)
{
timer_list_t
*
list
=
timerMap
.
slots
+
i
;
tmr_obj_t
*
t
=
list
->
timers
;
while
(
t
!=
NULL
)
{
tmr_obj_t
*
next
=
t
->
mnext
;
free
(
t
);
t
=
next
;
}
}
free
(
timerMap
.
slots
);
free
(
tmrCtrls
);
taosCleanUpScheduler
(
tmrQhandle
);
tmrModuleInit
=
PTHREAD_ONCE_INIT
;
tmrTrace
(
"timer module is cleaned up"
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录