Merge pull request #865 from taosdata/hotfix/fix-wrong-log
fix wrong log in timer
This commit is contained in:
commit
861e36f5e9
|
@ -254,13 +254,13 @@ static void processExpiredTimer(void* handle, void* arg) {
|
||||||
timer->executedBy = taosGetPthreadId();
|
timer->executedBy = taosGetPthreadId();
|
||||||
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_EXPIRED);
|
||||||
if (state == TIMER_STATE_WAITING) {
|
if (state == TIMER_STATE_WAITING) {
|
||||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution start.";
|
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] execution start.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
|
|
||||||
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
(*timer->fp)(timer->param, (tmr_h)timer->id);
|
||||||
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
atomic_store_8(&timer->state, TIMER_STATE_STOPPED);
|
||||||
|
|
||||||
fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] execution end.";
|
fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] execution end.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
}
|
}
|
||||||
removeTimer(timer->id);
|
removeTimer(timer->id);
|
||||||
|
@ -268,7 +268,7 @@ static void processExpiredTimer(void* handle, void* arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addToExpired(tmr_obj_t* head) {
|
static void addToExpired(tmr_obj_t* head) {
|
||||||
const char* fmt = "%s adding expired timer[id=" PRIuPTR ", fp=%p, param=%p] to queue.";
|
const char* fmt = "%s adding expired timer[id=%" PRIuPTR ", fp=%p, param=%p] to queue.";
|
||||||
|
|
||||||
while (head != NULL) {
|
while (head != NULL) {
|
||||||
uintptr_t id = head->id;
|
uintptr_t id = head->id;
|
||||||
|
@ -282,7 +282,7 @@ static void addToExpired(tmr_obj_t* head) {
|
||||||
schedMsg.thandle = NULL;
|
schedMsg.thandle = NULL;
|
||||||
taosScheduleTask(tmrQhandle, &schedMsg);
|
taosScheduleTask(tmrQhandle, &schedMsg);
|
||||||
|
|
||||||
tmrTrace("timer[id=" PRIuPTR "] has been added to queue.", id);
|
tmrTrace("timer[id=%" PRIuPTR "] has been added to queue.", id);
|
||||||
head = next;
|
head = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ static uintptr_t doStartTimer(tmr_obj_t* timer, TAOS_TMR_CALLBACK fp, int msecon
|
||||||
timer->ctrl = ctrl;
|
timer->ctrl = ctrl;
|
||||||
addTimer(timer);
|
addTimer(timer);
|
||||||
|
|
||||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] started";
|
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] started";
|
||||||
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
|
|
||||||
if (mseconds == 0) {
|
if (mseconds == 0) {
|
||||||
|
@ -389,7 +389,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||||
// we cannot guarantee the thread safety of the timr in all other cases.
|
// we cannot guarantee the thread safety of the timr in all other cases.
|
||||||
reusable = true;
|
reusable = true;
|
||||||
}
|
}
|
||||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is cancelled.";
|
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] is cancelled.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
return reusable;
|
return reusable;
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ static bool doStopTimer(tmr_obj_t* timer, uint8_t state) {
|
||||||
// timer callback is executing in another thread, we SHOULD wait it to stop,
|
// 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
|
// 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.
|
// the timer callback need to acquire. so, we HAVE TO return directly.
|
||||||
const char* fmt = "%s timer[id=" PRIuPTR ", fp=%p, param=%p] is executing and cannot be stopped.";
|
const char* fmt = "%s timer[id=%" PRIuPTR ", fp=%p, param=%p] is executing and cannot be stopped.";
|
||||||
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
tmrTrace(fmt, timer->ctrl->label, timer->id, timer->fp, timer->param);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +419,7 @@ bool taosTmrStop(tmr_h timerId) {
|
||||||
|
|
||||||
tmr_obj_t* timer = findTimer(id);
|
tmr_obj_t* timer = findTimer(id);
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
tmrTrace("timer[id=" PRIuPTR "] does not exist", id);
|
tmrTrace("timer[id=%" PRIuPTR "] does not exist", id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
||||||
bool stopped = false;
|
bool stopped = false;
|
||||||
tmr_obj_t* timer = findTimer(id);
|
tmr_obj_t* timer = findTimer(id);
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
tmrTrace("%s timer[id=" PRIuPTR "] does not exist", ctrl->label, id);
|
tmrTrace("%s timer[id=%" PRIuPTR "] does not exist", ctrl->label, id);
|
||||||
} else {
|
} else {
|
||||||
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
uint8_t state = atomic_val_compare_exchange_8(&timer->state, TIMER_STATE_WAITING, TIMER_STATE_CANCELED);
|
||||||
if (!doStopTimer(timer, state)) {
|
if (!doStopTimer(timer, state)) {
|
||||||
|
@ -461,7 +461,7 @@ bool taosTmrReset(TAOS_TMR_CALLBACK fp, int mseconds, void* param, void* handle,
|
||||||
return stopped;
|
return stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmrTrace("%s timer[id=" PRIuPTR "] is reused", ctrl->label, timer->id);
|
tmrTrace("%s timer[id=%" PRIuPTR "] is reused", ctrl->label, timer->id);
|
||||||
|
|
||||||
// wait until there's no other reference to this timer,
|
// wait until there's no other reference to this timer,
|
||||||
// so that we can reuse this timer safely.
|
// so that we can reuse this timer safely.
|
||||||
|
|
Loading…
Reference in New Issue