1
0
mirror of https://github.com/golang/go synced 2024-11-27 04:01:19 -07:00

syscall: treat ENFILE as a temporary error

ENFILE is returned from accept when the whole system has run out of
file descriptors. Mark the error as temporary, so that accept loops
continue working.

Fixes #35131
Updates #1891

Change-Id: Idf44c084731898ff4c720d06c250d3b8a42de312
Reviewed-on: https://go-review.googlesource.com/c/go/+/203117
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Lorenz Bauer 2019-10-30 11:30:57 +00:00 committed by Ian Lance Taylor
parent f4e32aeed1
commit 17190de085
2 changed files with 7 additions and 1 deletions

View File

@ -138,7 +138,7 @@ func (e Errno) Is(target error) bool {
} }
func (e Errno) Temporary() bool { func (e Errno) Temporary() bool {
return e == EINTR || e == EMFILE || e.Timeout() return e == EINTR || e == EMFILE || e == ENFILE || e.Timeout()
} }
func (e Errno) Timeout() bool { func (e Errno) Timeout() bool {

View File

@ -384,3 +384,9 @@ func TestSetsockoptString(t *testing.T) {
t.Fatalf("SetsockoptString: did not fail") t.Fatalf("SetsockoptString: did not fail")
} }
} }
func TestENFILETemporary(t *testing.T) {
if !syscall.ENFILE.Temporary() {
t.Error("ENFILE is not treated as a temporary error")
}
}