Fix-Point commented on code in PR #16231: URL: https://github.com/apache/nuttx/pull/16231#discussion_r2074674647
########## sched/wqueue/kwork_cancel.c: ########## @@ -59,17 +59,37 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, */ flags = spin_lock_irqsave(&wqueue->lock); - if (work->worker != NULL) + + /* Check whether we own the work structure. */ + + if (!work_available(work)) { - /* Remove the entry from the work queue and make sure that it is - * marked as available (i.e., the worker field is nullified). - */ + bool is_head = list_is_head(&wqueue->pending, &work->node); + + /* Seize the ownership from the work thread. */ work->worker = NULL; - wd_cancel(&work->u.timer); - list_delete(&work->u.s.node); - ret = OK; + list_delete(&work->node); + + /* If the head of the pending queue has changed, we should reset + * the wqueue timer. + */ + + if (is_head) + { + if (!list_is_empty(&wqueue->expired)) Review Comment: Done. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org