[TD-2373]<fix>: data race in removeFromWheel

This commit is contained in:
Bomin Zhang 2020-12-08 02:55:20 +00:00
parent 48ba8aeb90
commit c90ea80143
1 changed files with 3 additions and 2 deletions

View File

@ -225,10 +225,11 @@ static void addToWheel(tmr_obj_t* timer, uint32_t delay) {
}
static bool removeFromWheel(tmr_obj_t* timer) {
if (timer->wheel >= tListLen(wheels)) {
uint8_t wheelIdx = timer->wheel;
if (wheelIdx >= tListLen(wheels)) {
return false;
}
time_wheel_t* wheel = wheels + timer->wheel;
time_wheel_t* wheel = wheels + wheelIdx;
bool removed = false;
pthread_mutex_lock(&wheel->mutex);