aboutsummaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
authorWeerasak Chongnguluam <singpor@gmail.com>2017-07-21 01:53:55 +0700
committerBrad Fitzpatrick <bradfitz@golang.org>2018-10-03 15:26:10 +0000
commit119fafcaa5ace647961b59d304b275d93a3e6e97 (patch)
tree0dbbe43542fe400c3a84c013d2ca278c5c245524 /src/context
parentc96e3bcc97a965b3e2947cc1d8d831b8d39c1d73 (diff)
downloadgo-119fafcaa5ace647961b59d304b275d93a3e6e97.tar.gz
go-119fafcaa5ace647961b59d304b275d93a3e6e97.zip
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 <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/context')
-rw-r--r--src/context/context.go2
1 files changed, 1 insertions, 1 deletions
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()