Fix-Point commented on code in PR #16231: URL: https://github.com/apache/nuttx/pull/16231#discussion_r2051350399
########## sched/wqueue/kwork_cancel.c: ########## @@ -59,37 +61,36 @@ 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). - */ + /* Seize the ownership from the work thread. */ + worker = work->worker; + arg = work->arg; + + run_myself = sync; work->worker = NULL; - wd_cancel(&work->u.timer); - list_delete(&work->u.s.node); - ret = OK; + list_delete(&work->node); } - else if (!up_interrupt_context() && !sched_idletask() && sync) + + spin_unlock_irqrestore(&wqueue->lock, flags); + + if (run_myself) { - int wndx; - - for (wndx = 0; wndx < wqueue->nthreads; wndx++) - { - if (wqueue->worker[wndx].work == work && - wqueue->worker[wndx].pid != nxsched_gettid()) Review Comment: This block is not required anymore since the cancel thread will complete the unfinished work by itself. -- 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