fix: avoid timeout event lost

This commit is contained in:
yihaoDeng 2022-06-17 21:46:09 +08:00
parent b2924fd9c7
commit 3d15b65cea
2 changed files with 18 additions and 16 deletions

View File

@ -376,17 +376,19 @@ static void transDQTimeout(uv_timer_t* timer) {
SDelayQueue* queue = timer->data;
tTrace("timer %p timeout", timer);
uint64_t timeout = 0;
int64_t current = taosGetTimestampMs();
do {
HeapNode* minNode = heapMin(queue->heap);
if (minNode == NULL) break;
SDelayTask* task = container_of(minNode, SDelayTask, node);
if (task->execTime <= taosGetTimestampMs()) {
if (task->execTime <= current) {
heapRemove(queue->heap, minNode);
task->func(task->arg);
taosMemoryFree(task);
timeout = 0;
} else {
timeout = task->execTime - taosGetTimestampMs();
timeout = task->execTime - current;
break;
}
} while (1);