Commit 119fafca authored by Weerasak Chongnguluam's avatar Weerasak Chongnguluam Committed by Brad Fitzpatrick

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent c96e3bcc
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment