runtime: convert linux netpollWakeSig to atomic type

Updates #53821

Change-Id: If4090393a127c2f468c8ae5ba478a9f59d73b945
Reviewed-on: https://go-review.googlesource.com/c/go/+/423876
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Cuong Manh Le 2022-08-17 16:13:09 +07:00
parent edfeea01be
commit 901b9233e6

View file

@ -26,7 +26,7 @@ var (
netpollBreakRd, netpollBreakWr uintptr // for netpollBreak
netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
netpollWakeSig atomic.Uint32 // used to avoid duplicate calls of netpollBreak
)
func netpollinit() {
@ -80,7 +80,7 @@ func netpollarm(pd *pollDesc, mode int) {
// netpollBreak interrupts an epollwait.
func netpollBreak() {
// Failing to cas indicates there is an in-flight wakeup, so we're done here.
if !atomic.Cas(&netpollWakeSig, 0, 1) {
if !netpollWakeSig.CompareAndSwap(0, 1) {
return
}
@ -157,7 +157,7 @@ retry:
// if blocking.
var tmp [16]byte
read(int32(netpollBreakRd), noescape(unsafe.Pointer(&tmp[0])), int32(len(tmp)))
atomic.Store(&netpollWakeSig, 0)
netpollWakeSig.Store(0)
}
continue
}