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) } }