未验证 提交 b128febb 编写于 作者: 陶建辉(Jeff)'s avatar 陶建辉(Jeff) 提交者: GitHub

Merge pull request #1849 from haoyifan/timer_fix

[Timer] Initialize the last tmrCtrls.
......@@ -405,19 +405,19 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
return reusable;
}
if (state != TIMER_STATE_EXPIRED) {
// timer already stopped or cancelled, has nothing to do in this case
return false;
}
if (timer->executedBy == taosGetPthreadId()) {
// taosTmrReset is called in the timer callback, should do nothing in this
// case to avoid dead lock. note taosTmrReset must be the last statement
// of the callback funtion, will be a bug otherwise.
return false;
}
// timer callback is executing in another thread, we SHOULD wait it to stop,
// BUT this may result in dead lock if current thread are holding a lock which
// the timer callback need to acquire. so, we HAVE TO return directly.
......@@ -501,6 +501,7 @@ static void taosTmrModuleInit(void) {
tmr_ctrl_t* ctrl = tmrCtrls + i;
ctrl->next = ctrl + 1;
}
(tmrCtrls + taosMaxTmrCtrl - 1)->next = NULL;
unusedTmrCtrl = tmrCtrls;
pthread_mutex_init(&tmrCtrlMutex, NULL);
......@@ -574,12 +575,12 @@ void taosTmrCleanUp(void* handle) {
if (numOfTmrCtrl <=0) {
taosUninitTimer();
taosCleanUpScheduler(tmrQhandle);
for (int i = 0; i < tListLen(wheels); i++) {
time_wheel_t* wheel = wheels + i;
pthread_mutex_destroy(&wheel->mutex);
pthread_mutex_destroy(&wheel->mutex);
free(wheel->slots);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册