From: Weerasak Chongnguluam Date: Thu, 20 Jul 2017 18:53:55 +0000 (+0700) Subject: context: avoid duplicate removeChild X-Git-Tag: go1.12beta1~927 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=119fafcaa5ace647961b59d304b275d93a3e6e97;p=gostls13.git context: avoid duplicate removeChild When deadline has already passed, current context is canceled before return cancel function. So is unnecessary to call cancel with remove from parent again in return cancel function. Change-Id: I37c687c57a29d9f139c7fb648ce7de69093ed623 Reviewed-on: https://go-review.googlesource.com/c/50410 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/context/context.go b/src/context/context.go index 85f8acf8fa..21a40d5947 100644 --- a/src/context/context.go +++ b/src/context/context.go @@ -393,7 +393,7 @@ func WithDeadline(parent Context, d time.Time) (Context, CancelFunc) { dur := time.Until(d) if dur <= 0 { c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } + return c, func() { c.cancel(false, Canceled) } } c.mu.Lock() defer c.mu.Unlock()