diff options
author | Ian Lance Taylor <iant@golang.org> | 2019-04-05 15:53:12 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2019-10-21 16:37:45 +0000 |
commit | 50f4896b72d16b6538178c8ca851b20655075b7f (patch) | |
tree | ac9868bddb566d8895e541450bf7059f7f006098 /src/runtime/netpoll_aix.go | |
parent | 33425ab8dbb03c355b2263b8250a1829e260d66f (diff) | |
download | go-50f4896b72d16b6538178c8ca851b20655075b7f.tar.gz go-50f4896b72d16b6538178c8ca851b20655075b7f.zip |
runtime: add netpollBreak
The new netpollBreak function can be used to interrupt a blocking netpoll.
This function is not currently used; it will be used by later CLs.
Updates #27707
Change-Id: I5cb936609ba13c3c127ea1368a49194fc58c9f4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/171824
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/netpoll_aix.go')
-rw-r--r-- | src/runtime/netpoll_aix.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/runtime/netpoll_aix.go b/src/runtime/netpoll_aix.go index 6feda27b80..e1512f826c 100644 --- a/src/runtime/netpoll_aix.go +++ b/src/runtime/netpoll_aix.go @@ -63,12 +63,8 @@ func netpollinit() { pds[0] = nil } -func netpolldescriptor() uintptr { - // Both fd must be returned - if rdwake > 0xFFFF || wrwake > 0xFFFF { - throw("netpolldescriptor: invalid fd number") - } - return uintptr(rdwake<<16 | wrwake) +func netpollIsPollDescriptor(fd uintptr) bool { + return fd == uintptr(rdwake) || fd == uintptr(wrwake) } // netpollwakeup writes on wrwake to wakeup poll before any changes. @@ -132,6 +128,11 @@ func netpollarm(pd *pollDesc, mode int) { unlock(&mtxset) } +// netpollBreak interrupts an epollwait. +func netpollBreak() { + netpollwakeup() +} + // netpoll checks for ready network connections. // Returns list of goroutines that become runnable. // delay < 0: blocks indefinitely @@ -176,8 +177,13 @@ retry: } // Check if some descriptors need to be changed if n != 0 && pfds[0].revents&(_POLLIN|_POLLHUP|_POLLERR) != 0 { - var b [1]byte - for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 { + if delay != 0 { + // A netpollwakeup could be picked up by a + // non-blocking poll. Only clear the wakeup + // if blocking. + var b [1]byte + for read(rdwake, unsafe.Pointer(&b[0]), 1) == 1 { + } } // Do not look at the other fds in this case as the mode may have changed // XXX only additions of flags are made, so maybe it is ok |