mirror of
https://github.com/golang/go
synced 2024-11-17 23:04:56 -07:00
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>
This commit is contained in:
parent
4af639a568
commit
04e80fb2c9
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user