aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-11-01 16:31:57 -0700
committerIan Lance Taylor <iant@golang.org>2019-11-05 00:17:34 +0000
commit04e80fb2c9e502c011d367ad36307290df07cb41 (patch)
treed473935d392fa9eb7687582703281c64cd9d8a85 /src/runtime
parent4af639a5685355b22f8a541c72ba092bed768941 (diff)
downloadgo-04e80fb2c9e502c011d367ad36307290df07cb41.tar.xz
runtime: don't return from netpollGenericInit until init is complete
As a side-effect ensure that netpollinited only reports true when netpoll initialization is complete. Fixes #35282 Updates #35353 Change-Id: I21f08a04fcf229e0de5e6b5ad89c990426ae9b89 Reviewed-on: https://go-review.googlesource.com/c/go/+/204937 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/netpoll.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/runtime/netpoll.go b/src/runtime/netpoll.go
index 939b27061e..25b1d5d49e 100644
--- a/src/runtime/netpoll.go
+++ b/src/runtime/netpoll.go
@@ -93,7 +93,9 @@ type pollCache struct {
}
var (
- netpollInited uint32
+ netpollInitLock mutex
+ netpollInited uint32
+
pollcache pollCache
netpollWaiters uint32
)
@@ -104,8 +106,13 @@ func poll_runtime_pollServerInit() {
}
func netpollGenericInit() {
- if atomic.Cas(&netpollInited, 0, 1) {
- netpollinit()
+ if atomic.Load(&netpollInited) == 0 {
+ lock(&netpollInitLock)
+ if netpollInited == 0 {
+ netpollinit()
+ atomic.Store(&netpollInited, 1)
+ }
+ unlock(&netpollInitLock)
}
}