Skip to content

Commit

Permalink
init MaxOpenFiles by process limit
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal authored Oct 20, 2022
1 parent 6ede89e commit 97a0ab4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ import (
"syscall"
)

func init() {
var limit syscall.Rlimit
if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limit); err ==nil {
if n := int(limit.Max); n > 0 {
MaxOpenFiles = n
}
}
}

//go:norace
func dupStdConn(conn net.Conn) (*Conn, error) {
sc, ok := conn.(interface {
Expand Down

0 comments on commit 97a0ab4

Please sign in to comment.