aboutsummaryrefslogtreecommitdiff
path: root/src/context
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2022-08-08 21:51:01 +0700
committerGopher Robot <gobot@golang.org>2022-08-08 16:05:18 +0000
commit487b3501a54e5479972a7982fe1eb154f0447b58 (patch)
tree2891daff8fca18d4aa999a350f152c8e87da8fd9 /src/context
parentadac8acf881ac48c558a4873b4cc7551c7e592b1 (diff)
downloadgo-487b3501a54e5479972a7982fe1eb154f0447b58.tar.gz
go-487b3501a54e5479972a7982fe1eb154f0447b58.zip
context: Revert "context: use CompareAndSwap in cancelCtx.Done"
This reverts commit 964f0c7a306998256f1c5a5fd78fc457a972f001. Reason: cause increasing timeout in crypto/tls tests on race builders. Change-Id: Id16d4fcd19c2ca2e89ad4d0c9d55ef1105b19c76 Reviewed-on: https://go-review.googlesource.com/c/go/+/422035 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/context')
-rw-r--r--src/context/context.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/context/context.go b/src/context/context.go
index 04ac080402..1070111efa 100644
--- a/src/context/context.go
+++ b/src/context/context.go
@@ -360,8 +360,14 @@ func (c *cancelCtx) Done() <-chan struct{} {
if d != nil {
return d.(chan struct{})
}
- c.done.CompareAndSwap(nil, make(chan struct{}))
- return c.done.Load().(chan struct{})
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ d = c.done.Load()
+ if d == nil {
+ d = make(chan struct{})
+ c.done.Store(d)
+ }
+ return d.(chan struct{})
}
func (c *cancelCtx) Err() error {