]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: on unexpected netpoll error, throw instead of looping
authorIan Lance Taylor <iant@golang.org>
Fri, 10 Jul 2015 22:28:01 +0000 (15:28 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Sep 2015 17:56:56 +0000 (17:56 +0000)
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/12047
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
src/runtime/netpoll_epoll.go
src/runtime/netpoll_kqueue.go
src/runtime/netpoll_solaris.go

index 7b4052a2627786fc98da09647ef69b99e1b1619e..e06eff83be1e2744cb9252e882ddbc0342e7de7e 100644 (file)
@@ -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
        }
index 01445dc231f80121c73ad2c24c0a9058424437ab..36956bae7171b5439c2f3b2eff1d5044a6e0a9e6 100644 (file)
@@ -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
        }
index e4652d8ebd746b6afd0c94a6b62ec0cd54882eda..86e9b997ef658b93a0c8d4b3f8fb576d58a53cf9 100644 (file)
@@ -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
        }