1
0
mirror of https://github.com/golang/go synced 2024-11-26 14:36:52 -07:00

runtime: does not report duplicate errors in netpoll

Prevents storm of error messages if something goes wrong.
In the case of issue 5073 the epoll fd was closed by the test.
Update #5073.

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/7966043
This commit is contained in:
Dmitriy Vyukov 2013-03-26 20:25:43 +04:00
parent 9d97b55d38
commit 94599ea745
2 changed files with 10 additions and 4 deletions

View File

@ -57,6 +57,7 @@ runtime·netpollclose(int32 fd)
G* G*
runtime·netpoll(bool block) runtime·netpoll(bool block)
{ {
static int32 lasterr;
EpollEvent events[128], *ev; EpollEvent events[128], *ev;
int32 n, i, waitms, mode; int32 n, i, waitms, mode;
G *gp; G *gp;
@ -69,8 +70,10 @@ runtime·netpoll(bool block)
retry: retry:
n = runtime·epollwait(epfd, events, nelem(events), waitms); n = runtime·epollwait(epfd, events, nelem(events), waitms);
if(n < 0) { if(n < 0) {
if(n != -EINTR) if(n != -EINTR && n != lasterr) {
runtime·printf("epollwait failed with %d\n", -n); lasterr = n;
runtime·printf("runtime: epollwait on fd %d failed with %d\n", epfd, -n);
}
goto retry; goto retry;
} }
gp = nil; gp = nil;

View File

@ -71,6 +71,7 @@ runtime·netpollclose(int32 fd)
G* G*
runtime·netpoll(bool block) runtime·netpoll(bool block)
{ {
static int32 lasterr;
Kevent events[64], *ev; Kevent events[64], *ev;
Timespec ts, *tp; Timespec ts, *tp;
int32 n, i; int32 n, i;
@ -88,8 +89,10 @@ runtime·netpoll(bool block)
retry: retry:
n = runtime·kevent(kq, nil, 0, events, nelem(events), tp); n = runtime·kevent(kq, nil, 0, events, nelem(events), tp);
if(n < 0) { if(n < 0) {
if(n != -EINTR) if(n != -EINTR && n != lasterr) {
runtime·printf("kqueue failed with %d\n", -n); lasterr = n;
runtime·printf("runtime: kevent on fd %d failed with %d\n", kq, -n);
}
goto retry; goto retry;
} }
for(i = 0; i < n; i++) { for(i = 0; i < n; i++) {