aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/netpoll_aix.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/runtime/netpoll_aix.go')
-rw-r--r--libgo/go/runtime/netpoll_aix.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/libgo/go/runtime/netpoll_aix.go b/libgo/go/runtime/netpoll_aix.go
index a00742e..bb6ce37 100644
--- a/libgo/go/runtime/netpoll_aix.go
+++ b/libgo/go/runtime/netpoll_aix.go
@@ -4,7 +4,10 @@
package runtime
-import "unsafe"
+import (
+ "runtime/internal/atomic"
+ "unsafe"
+)
// This is based on the former libgo/runtime/netpoll_select.c implementation
// except that it uses poll instead of select and is written in Go.
@@ -34,6 +37,8 @@ var (
rdwake int32
wrwake int32
pendingUpdates int32
+
+ netpollWakeSig uint32 // used to avoid duplicate calls of netpollBreak
)
func netpollinit() {
@@ -121,9 +126,12 @@ func netpollarm(pd *pollDesc, mode int) {
unlock(&mtxset)
}
-// netpollBreak interrupts an epollwait.
+// netpollBreak interrupts a poll.
func netpollBreak() {
- netpollwakeup()
+ if atomic.Cas(&netpollWakeSig, 0, 1) {
+ b := [1]byte{0}
+ write(uintptr(wrwake), unsafe.Pointer(&b[0]), 1)
+ }
}
// netpoll checks for ready network connections.
@@ -178,6 +186,7 @@ retry:
var b [1]byte
for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 {
}
+ atomic.Store(&netpollWakeSig, 0)
}
// Still look at the other fds even if the mode may have
// changed, as netpollBreak might have been called.