-
Notifications
You must be signed in to change notification settings - Fork 1.7k
sched/wqueue: Fix work_cancel() to return -ENOENT when no such work is queued #20046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,9 @@ | |
| static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, | ||
| FAR struct work_s *work) | ||
| { | ||
| irqstate_t flags; | ||
| FAR sem_t *sync_wait = NULL; | ||
| irqstate_t flags; | ||
| int ret = 0; | ||
|
|
||
| if (wqueue == NULL || work == NULL) | ||
| { | ||
|
|
@@ -71,6 +72,10 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, | |
| work_timer_reset(wqueue); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| ret = -ENOENT; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not return, but to through the remaining code
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. early return will change the behavior of this function for sync path. I haven't analyzed the consequences of this, so no early return.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, but why return -ENOENT in this case? it's fine to return OK if work isn't queued yet since the final result is that the work doesn't fire anyway. |
||
| } | ||
|
|
||
| /* Note that cancel_sync can not be called in the interrupt | ||
| * context and the idletask context. | ||
|
|
@@ -102,7 +107,7 @@ static int work_qcancel(FAR struct kwork_wqueue_s *wqueue, bool sync, | |
| nxsem_wait_uninterruptible(sync_wait); | ||
| } | ||
|
|
||
| return 0; | ||
| return ret; | ||
| } | ||
|
|
||
| /**************************************************************************** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.