]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: convert windows netpollWakeSig to atomic type
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 09:21:00 +0000 (16:21 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Wed, 17 Aug 2022 17:39:50 +0000 (17:39 +0000)
Updates #53821

Change-Id: Ifc5bc551a4bcf82bf10d2e670ad2644eb9c6b334
Reviewed-on: https://go-review.googlesource.com/c/go/+/423879
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

src/runtime/netpoll_windows.go

index 7e4664909ccdac49b460c33c33896a1d3e8e839d..796bf1dd19529a85cbc7ea3c1b5e0009695b9d3a 100644 (file)
@@ -35,7 +35,7 @@ type overlappedEntry struct {
 var (
        iocphandle uintptr = _INVALID_HANDLE_VALUE // completion port io handle
 
-       netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
+       netpollWakeSig atomic.Uint32 // used to avoid duplicate calls of netpollBreak
 )
 
 func netpollinit() {
@@ -68,7 +68,7 @@ func netpollarm(pd *pollDesc, mode int) {
 
 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
        }
 
@@ -136,7 +136,7 @@ func netpoll(delay int64) gList {
                        }
                        handlecompletion(&toRun, op, errno, qty)
                } else {
-                       atomic.Store(&netpollWakeSig, 0)
+                       netpollWakeSig.Store(0)
                        if delay == 0 {
                                // Forward the notification to the
                                // blocked poller.