On Mon, Apr 26, 2021 at 9:59 AM qinggeer Bao <
bao...@gmail.com> wrote:
>
> if parentCancelCtx return false, it means no cancellable ancestors found, then why do we need run another goroutine to listen for parent's cancel signals? How it can happen in what kind of cases?
See the documentation of parentCancelCtx: "If not, the *cancelCtx has
been wrapped in a custom implementation providing a different done
channel, in which case we should not bypass it." In other words,
people can and do provide their own custom implementations of the
context.Context interface. For those implementations, parentCancelCtx
will return nil, but that doesn't mean that the custom implementation
can't be cancelled. propagateCancel has to handle that case
correctly. See also XTestWithCancel and
XTestWithCancelCanceledParent.
Ian