Commit b6d115a5 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: on unexpected netpoll error, throw instead of looping

The current code prints an error message and then tries to carry on.
This is not helpful for Go users: they see a message that means
nothing and that they can do nothing about.  In the only known case of
this message, in issue 11498, the best guess is that the netpoll code
went into an infinite loop.  Instead of doing that, crash the program.

Fixes #11498.

Change-Id: Idda3456c5b708f0df6a6b56c5bb4e796bbc39d7c
Reviewed-on: https://go-review.googlesource.com/12047Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
parent 731bdc51
......@@ -19,8 +19,7 @@ func epollwait(epfd int32, ev *epollevent, nev, timeout int32) int32
func closeonexec(fd int32)
var (
epfd int32 = -1 // epoll descriptor
netpolllasterr int32
epfd int32 = -1 // epoll descriptor
)
func netpollinit() {
......@@ -67,9 +66,9 @@ func netpoll(block bool) *g {
retry:
n := epollwait(epfd, &events[0], int32(len(events)), waitms)
if n < 0 {
if n != -_EINTR && n != netpolllasterr {
netpolllasterr = n
if n != -_EINTR {
println("runtime: epollwait on fd", epfd, "failed with", -n)
throw("epollwait failed")
}
goto retry
}
......
......@@ -17,8 +17,7 @@ func kevent(kq int32, ch *keventt, nch int32, ev *keventt, nev int32, ts *timesp
func closeonexec(fd int32)
var (
kq int32 = -1
netpolllasterr int32
kq int32 = -1
)
func netpollinit() {
......@@ -75,9 +74,9 @@ func netpoll(block bool) *g {
retry:
n := kevent(kq, nil, 0, &events[0], int32(len(events)), tp)
if n < 0 {
if n != -_EINTR && n != netpolllasterr {
netpolllasterr = n
if n != -_EINTR {
println("runtime: kevent on fd", kq, "failed with", -n)
throw("kevent failed")
}
goto retry
}
......
......@@ -174,9 +174,6 @@ func netpollarm(pd *pollDesc, mode int) {
unlock(&pd.lock)
}
// netpolllasterr holds the last error code returned by port_getn to prevent log spamming
var netpolllasterr int32
// polls for ready network connections
// returns list of goroutines that become runnable
func netpoll(block bool) *g {
......@@ -194,9 +191,9 @@ func netpoll(block bool) *g {
retry:
var n uint32 = 1
if port_getn(portfd, &events[0], uint32(len(events)), &n, wait) < 0 {
if e := errno(); e != _EINTR && e != netpolllasterr {
netpolllasterr = e
if e := errno(); e != _EINTR {
print("runtime: port_getn on fd ", portfd, " failed with ", e, "\n")
throw("port_getn failed")
}
goto retry
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment