[Timer] Initialize the last tmrCtrls.

While initialize timer module, tmrCtrls is constructed to be a free
list. However, the last tmrCtrls is never initialized, which is
allocated from malloc(). Since the code relies on tmrCtrls->next
to tell if there's any free tmrCtrls left, the last tmrCtrls should
be properly linked to NULL.
This commit is contained in:
yifan hao 2020-05-08 18:52:17 -06:00
parent 15d6f34de7
commit ba7acaa5bc
1 changed files with 6 additions and 5 deletions

View File

@ -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);