From 04d8c2327d5a2788757f22fd0e23198f7045c20f Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Wed, 17 Aug 2022 16:22:13 +0700 Subject: [PATCH] runtime: convert kqueue netpollWakeSig to atomic type Updates #53821 Change-Id: I85d7444be36967e1e7e0ff2ce2f19b73581ecdde Reviewed-on: https://go-review.googlesource.com/c/go/+/423880 Run-TryBot: Cuong Manh Le Reviewed-by: Michael Pratt Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Auto-Submit: Cuong Manh Le --- src/runtime/netpoll_kqueue.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/netpoll_kqueue.go b/src/runtime/netpoll_kqueue.go index 78d1663ad9..5ae77b57f2 100644 --- a/src/runtime/netpoll_kqueue.go +++ b/src/runtime/netpoll_kqueue.go @@ -18,7 +18,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() { @@ -84,7 +84,7 @@ func netpollarm(pd *pollDesc, mode int) { // netpollBreak interrupts a kevent. 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 } @@ -155,7 +155,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 } -- 2.50.0