]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: treat ENFILE as a temporary error
authorLorenz Bauer <lmb@cloudflare.com>
Wed, 30 Oct 2019 11:30:57 +0000 (11:30 +0000)
committerIan Lance Taylor <iant@golang.org>
Wed, 30 Oct 2019 14:06:04 +0000 (14:06 +0000)
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>
src/syscall/syscall_unix.go
src/syscall/syscall_unix_test.go

index 457be311c4fdf9d7b23ad7fb0366745e2f3f125d..b8b8a7c111b365a7db5cc9f7e7abef8917caa94d 100644 (file)
@@ -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 {
index 62109ac3e7fa000db2971220201c4451f306f301..ff47a0c81a2491fe77fe43b815db12f16036e47f 100644 (file)
@@ -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")
+       }
+}