]> Cypherpunks repositories - gostls13.git/commitdiff
net: don't assume that NOFILE rlimit fits in an int
authorIan Lance Taylor <iant@golang.org>
Sun, 26 Mar 2023 03:05:38 +0000 (20:05 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 27 Mar 2023 21:54:52 +0000 (21:54 +0000)
No test because a test requires a system on which we can set RLIMIT_NOFILE
to RLIM_INFINITY, which we normally can't.

Fixes #59242

Change-Id: I8fc30e4206bb2be46369b5342360de556ce75a96
Reviewed-on: https://go-review.googlesource.com/c/go/+/479436
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/net/lookup_unix.go

index 600e69404418def00b89d0cd8b99ce5e5d35c9ed..3c67b9ecc838bc92d1461539dc080453e6b372e2 100644 (file)
@@ -148,11 +148,11 @@ func concurrentThreadsLimit() int {
        if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil {
                return 500
        }
-       r := int(rlim.Cur)
+       r := rlim.Cur
        if r > 500 {
                r = 500
        } else if r > 30 {
                r -= 30
        }
-       return r
+       return int(r)
 }