From 119fafcaa5ace647961b59d304b275d93a3e6e97 Mon Sep 17 00:00:00 2001 From: Weerasak Chongnguluam Date: Fri, 21 Jul 2017 01:53:55 +0700 Subject: [PATCH] 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 --- src/context/context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() -- 2.48.1