Skip to content

Commit

Permalink
syscall: treat ENFILE as a temporary error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lmb authored and ianlancetaylor committed Oct 30, 2019
1 parent f4e32ae commit 17190de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/syscall/syscall_unix.go
Expand Up @@ -138,7 +138,7 @@ func (e Errno) Is(target error) 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 {
Expand Down
6 changes: 6 additions & 0 deletions src/syscall/syscall_unix_test.go
Expand Up @@ -384,3 +384,9 @@ func TestSetsockoptString(t *testing.T) {
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")
}
}

0 comments on commit 17190de

Please sign in to comment.