xiaoxiang781216 commented on a change in pull request #1187:
URL: https://github.com/apache/incubator-nuttx/pull/1187#discussion_r437874556
##########
File path: sched/task/task_cancelpt.c
##########
@@ -339,51 +344,89 @@ void nxnotify_cancellation(FAR struct tcb_s *tcb)
flags = enter_critical_section();
- /* Make sure that the cancellation pending indication is set. */
-
- tcb->flags |= TCB_FLAG_CANCEL_PENDING;
-
/* We only notify the cancellation if (1) the thread has not disabled
* cancellation, (2) the thread uses the deferred cancellation mode,
* (3) the thread is waiting within a cancellation point.
*/
- if (((tcb->flags & TCB_FLAG_NONCANCELABLE) == 0 &&
- (tcb->flags & TCB_FLAG_CANCEL_DEFERRED) != 0) ||
- tcb->cpcount > 0)
+ /* Check to see if this task has the non-cancelable bit set. */
+
+ if ((tcb->flags & TCB_FLAG_NONCANCELABLE) != 0)
{
- /* If the thread is blocked waiting for a semaphore, then the thread
- * must be unblocked to handle the cancellation.
+ /* Then we cannot cancel the thread now. Here is how this is
+ * supposed to work:
+ *
+ * "When cancellability is disabled, all cancels are held pending
+ * in the target thread until the thread changes the cancellability.
+ * When cancellability is deferred, all cancels are held pending in
+ * the target thread until the thread changes the cancellability,
+ * calls a function which is a cancellation point or calls
+ * pthread_testcancel(), thus creating a cancellation point. When
+ * cancellability is asynchronous, all cancels are acted upon
+ * immediately, interrupting the thread with its processing."
+ *
+ * REVISIT: Does this rule apply to equally to both SIGKILL and
+ * SIGINT?
Review comment:
The comment is copied from sig_default, I will remove it.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]