wqueue: teardown should cancel the work already in wqueue
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
42b6dd0ff1
commit
4d6203d4c6
@ -168,6 +168,10 @@ static void work_notifier_worker(FAR void *arg)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
|
/* Remove the notification from the pending list */
|
||||||
|
|
||||||
|
dq_rem((FAR dq_entry_t *)notifier, &g_notifier_pending);
|
||||||
|
|
||||||
/* Put the notification to the free list */
|
/* Put the notification to the free list */
|
||||||
|
|
||||||
dq_addlast((FAR dq_entry_t *)notifier, &g_notifier_free);
|
dq_addlast((FAR dq_entry_t *)notifier, &g_notifier_free);
|
||||||
@ -298,7 +302,11 @@ void work_notifier_teardown(int key)
|
|||||||
notifier = work_notifier_find(key);
|
notifier = work_notifier_find(key);
|
||||||
if (notifier != NULL)
|
if (notifier != NULL)
|
||||||
{
|
{
|
||||||
/* Found it! Remove the notification from the pending list */
|
/* Cancel the work, this may be waiting */
|
||||||
|
|
||||||
|
if (work_cancel_sync(notifier->info.qid, ¬ifier->work) != 1)
|
||||||
|
{
|
||||||
|
/* Remove the notification from the pending list */
|
||||||
|
|
||||||
dq_rem((FAR dq_entry_t *)notifier, &g_notifier_pending);
|
dq_rem((FAR dq_entry_t *)notifier, &g_notifier_pending);
|
||||||
|
|
||||||
@ -306,6 +314,7 @@ void work_notifier_teardown(int key)
|
|||||||
|
|
||||||
dq_addlast((FAR dq_entry_t *)notifier, &g_notifier_free);
|
dq_addlast((FAR dq_entry_t *)notifier, &g_notifier_free);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
@ -373,9 +382,9 @@ void work_notifier_signal(enum work_evtype_e evtype,
|
|||||||
|
|
||||||
if (info->evtype == evtype && info->qualifier == qualifier)
|
if (info->evtype == evtype && info->qualifier == qualifier)
|
||||||
{
|
{
|
||||||
/* Yes.. Remove the notification from the pending list */
|
/* Mark the notification as no longer pending */
|
||||||
|
|
||||||
dq_rem((FAR dq_entry_t *)notifier, &g_notifier_pending);
|
info->qualifier = NULL;
|
||||||
|
|
||||||
/* Schedule the work. The entire notifier entry is passed as an
|
/* Schedule the work. The entire notifier entry is passed as an
|
||||||
* argument to the work function because that function is
|
* argument to the work function because that function is
|
||||||
|
Loading…
Reference in New Issue
Block a user