Commit 04e80fb2 authored by Ian Lance Taylor's avatar Ian Lance Taylor

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: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 4af639a5
......@@ -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)
}
}
......
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