wqueue: delete sem_wait to avoid race condition

when work_cancel was called, we need to check work.timer whether is active
by WDOG_ISACTIVE for work_queue with delay.

The wdog cb has not been executed when the flag:active is cleared
and if we check flag:active at this moment, WDOG_ISACTIVE will return false.
so the work_cancel will sem_wait until post a semaphore, but all free hpwork_thread
also wait this semphore and their priority are high than caller, this will be a race
condition causing thread/task of calling work_cancel block.

Change-Id: Id86289da60bf967d1062c1cdaaf6959b4f6dd054
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
Jiuzhu Dong
2021-07-19 15:43:48 +08:00
committed by dongjiuzhu1
parent 932926d0d7
commit dc1c7a644a
-11
View File
@@ -87,17 +87,6 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue,
}
else
{
/* The sem_wait() can't call from interrupt handlers, so worker
* thread will still be awakened even if the work cancel is
* called in interrupt handlers, but work thread can handle
* this case with work empty in the work queue.
*/
if (up_interrupt_context() == false)
{
nxsem_wait(&wqueue->sem);
}
sq_rem((FAR sq_entry_t *)work, &wqueue->q);
}