From: Cuong Manh Le Date: Wed, 17 Aug 2022 09:13:09 +0000 (+0700) Subject: runtime: convert linux netpollWakeSig to atomic type X-Git-Tag: go1.20rc1~1591 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=901b9233e6eadc7b5235d4bb492c6b04f75cab9a;p=gostls13.git 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 Reviewed-by: Keith Randall Reviewed-by: Michael Pratt Auto-Submit: Cuong Manh Le TryBot-Result: Gopher Robot --- diff --git a/src/runtime/netpoll_epoll.go b/src/runtime/netpoll_epoll.go index 7ad2c8ab35..09da662c92 100644 --- a/src/runtime/netpoll_epoll.go +++ b/src/runtime/netpoll_epoll.go @@ -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 }