xiaoxiang781216 commented on code in PR #16231:
URL: https://github.com/apache/nuttx/pull/16231#discussion_r2050007021


##########
sched/wqueue/kwork_cancel.c:
##########
@@ -59,38 +59,20 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, 
bool sync,
    */
 
   flags = spin_lock_irqsave(&wqueue->lock);
+
+  /* Check whether we own the work structure. */
+
   if (work->worker != NULL)
     {
-      /* 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. */
 
       work->worker = NULL;
-      wd_cancel(&work->u.timer);
-      if (dq_inqueue((FAR dq_entry_t *)work, &wqueue->q))
-        {
-          dq_rem((FAR dq_entry_t *)work, &wqueue->q);
-        }
 
-      ret = OK;
-    }
-  else if (!up_interrupt_context() && !sched_idletask() && sync)
-    {
-      int wndx;
-
-      for (wndx = 0; wndx < wqueue->nthreads; wndx++)
-        {
-          if (wqueue->worker[wndx].work == work &&
-              wqueue->worker[wndx].pid != nxsched_gettid())
-            {
-              wqueue->worker[wndx].wait_count++;
-              spin_unlock_irqrestore(&wqueue->lock, flags);
-              nxsem_wait_uninterruptible(&wqueue->worker[wndx].wait);
-              return 1;
-            }
-        }
+      list_delete(&work->node);
     }
 
+  ret = OK;

Review Comment:
   no, you can't remove the sync version, since the caller need sync to avoid 
the race condition.



-- 
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

Reply via email to