From 17190de08570d36dda9b2904609271354cc3c64a Mon Sep 17 00:00:00 2001 From: Lorenz Bauer Date: Wed, 30 Oct 2019 11:30:57 +0000 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_unix.go | 2 +- src/syscall/syscall_unix_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/syscall/syscall_unix.go b/src/syscall/syscall_unix.go index 457be311c4fdf..b8b8a7c111b36 100644 --- a/src/syscall/syscall_unix.go +++ b/src/syscall/syscall_unix.go @@ -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 { diff --git a/src/syscall/syscall_unix_test.go b/src/syscall/syscall_unix_test.go index 62109ac3e7fa0..ff47a0c81a249 100644 --- a/src/syscall/syscall_unix_test.go +++ b/src/syscall/syscall_unix_test.go @@ -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") + } +}