aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/netpoll_solaris.go
diff options
context:
space:
mode:
authorJoshua M. Clulow <josh@sysmgr.org>2019-11-01 22:26:59 -0700
committerIan Lance Taylor <iant@golang.org>2019-11-02 05:36:43 +0000
commit971ec8728e27a3a9e0b0b26413e2b994c828f86d (patch)
tree41978ed17c0fbe3bf7927e906cf09775eee92acc /src/runtime/netpoll_solaris.go
parent1e4a358454987ef5104e45081c8e2ecdc9f32513 (diff)
downloadgo-971ec8728e27a3a9e0b0b26413e2b994c828f86d.tar.gz
go-971ec8728e27a3a9e0b0b26413e2b994c828f86d.zip
runtime: check for events when port_getn fails with ETIME
On illumos systems, and at least historically on Solaris systems, it is possible for port_getn(3C) calls to return some number of events and then fail with error ETIME. Generally we expect this to happen if the caller passes an nget value larger than 1 and calls with a timeout; if less than the requested number of events accumulate the system will still return them after timeout failure so the caller must check the updated nget value in the ETIME case. Note that although less likely this can still happen even when requesting just 1 event, especially with a short timeout value or on a busy system. Fixes #35261 Change-Id: I0d83251b69a2fadc64c4e8e280aa596e2e1548ba Reviewed-on: https://go-review.googlesource.com/c/go/+/204801 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/netpoll_solaris.go')
-rw-r--r--src/runtime/netpoll_solaris.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/runtime/netpoll_solaris.go b/src/runtime/netpoll_solaris.go
index 26bbe38d86..15818cb4ea 100644
--- a/src/runtime/netpoll_solaris.go
+++ b/src/runtime/netpoll_solaris.go
@@ -229,13 +229,21 @@ func netpoll(delay int64) gList {
var events [128]portevent
retry:
var n uint32 = 1
- if port_getn(portfd, &events[0], uint32(len(events)), &n, wait) < 0 {
- if e := errno(); e != _EINTR && e != _ETIME {
+ r := port_getn(portfd, &events[0], uint32(len(events)), &n, wait)
+ e := errno()
+ if r < 0 && e == _ETIME && n > 0 {
+ // As per port_getn(3C), an ETIME failure does not preclude the
+ // delivery of some number of events. Treat a timeout failure
+ // with delivered events as a success.
+ r = 0
+ }
+ if r < 0 {
+ if e != _EINTR && e != _ETIME {
print("runtime: port_getn on fd ", portfd, " failed (errno=", e, ")\n")
throw("runtime: netpoll failed")
}
- // If a timed sleep was interrupted, just return to
- // recalculate how long we should sleep now.
+ // If a timed sleep was interrupted and there are no events,
+ // just return to recalculate how long we should sleep now.
if delay > 0 {
return gList{}
}