aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/netpoll_aix.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2019-04-02 20:27:35 -0700
committerIan Lance Taylor <iant@golang.org>2019-10-15 20:29:56 +0000
commit831e3cfaa594ceb70c3cbeff2d31fddcd9a25a5e (patch)
tree6a5203ae8e7b24bce6e2c76986aecf17e039e4a7 /src/runtime/netpoll_aix.go
parent6da300b196df5fc3b33dd3bc87c477d46473abde (diff)
downloadgo-831e3cfaa594ceb70c3cbeff2d31fddcd9a25a5e.tar.gz
go-831e3cfaa594ceb70c3cbeff2d31fddcd9a25a5e.zip
runtime: change netpoll to take an amount of time to block
This new facility will be used by future CLs in this series. Change the only blocking call to netpoll to do the right thing when netpoll returns an empty list. Updates #6239 Updates #27707 Change-Id: I58b3c2903eda61a3698b1a4729ed0e81382bb1ed Reviewed-on: https://go-review.googlesource.com/c/go/+/171821 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/runtime/netpoll_aix.go')
-rw-r--r--src/runtime/netpoll_aix.go31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/runtime/netpoll_aix.go b/src/runtime/netpoll_aix.go
index f0ba09460e..08a9e42dd2 100644
--- a/src/runtime/netpoll_aix.go
+++ b/src/runtime/netpoll_aix.go
@@ -148,12 +148,27 @@ func netpollarm(pd *pollDesc, mode int) {
unlock(&mtxset)
}
+// netpoll checks for ready network connections.
+// Returns list of goroutines that become runnable.
+// delay < 0: blocks indefinitely
+// delay == 0: does not block, just polls
+// delay > 0: block for up to that many nanoseconds
//go:nowritebarrierrec
-func netpoll(block bool) gList {
- timeout := ^uintptr(0)
- if !block {
- timeout = 0
+func netpoll(delay int64) gList {
+ var timeout uintptr
+ if delay < 0 {
+ timeout = ^uintptr(0)
+ } else if delay == 0 {
+ // TODO: call poll with timeout == 0
return gList{}
+ } else if delay < 1e6 {
+ timeout = 1
+ } else if delay < 1e15 {
+ timeout = uintptr(delay / 1e6)
+ } else {
+ // An arbitrary cap on how long to wait for a timer.
+ // 1e9 ms == ~11.5 days.
+ timeout = 1e9
}
retry:
lock(&mtxpoll)
@@ -168,6 +183,11 @@ retry:
throw("poll failed")
}
unlock(&mtxset)
+ // If a timed sleep was interrupted, just return to
+ // recalculate how long we should sleep now.
+ if timeout > 0 {
+ return gList{}
+ }
goto retry
}
// Check if some descriptors need to be changed
@@ -203,8 +223,5 @@ retry:
}
}
unlock(&mtxset)
- if block && toRun.empty() {
- goto retry
- }
return toRun
}