mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Bump default gonet.ListenTCP backlog to 4096.
Fixes #7379 PiperOrigin-RevId: 445541836
This commit is contained in:
committed by
gVisor bot
parent
2d9f1c3329
commit
19e9ee104a
@@ -64,6 +64,14 @@ func NewTCPListener(s *stack.Stack, wq *waiter.Queue, ep tcpip.Endpoint) *TCPLis
|
||||
}
|
||||
}
|
||||
|
||||
// maxListenBacklog is set to be reasonably high for most uses of gonet. Go net
|
||||
// package uses the value in /proc/sys/net/core/somaxconn file in Linux as the
|
||||
// default listen backlog. The value below matches the default in common linux
|
||||
// distros.
|
||||
//
|
||||
// See: https://cs.opensource.google/go/go/+/refs/tags/go1.18.1:src/net/sock_linux.go;drc=refs%2Ftags%2Fgo1.18.1;l=66
|
||||
const maxListenBacklog = 4096
|
||||
|
||||
// ListenTCP creates a new TCPListener.
|
||||
func ListenTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProtocolNumber) (*TCPListener, error) {
|
||||
// Create a TCP endpoint, bind it, then start listening.
|
||||
@@ -83,7 +91,7 @@ func ListenTCP(s *stack.Stack, addr tcpip.FullAddress, network tcpip.NetworkProt
|
||||
}
|
||||
}
|
||||
|
||||
if err := ep.Listen(10); err != nil {
|
||||
if err := ep.Listen(maxListenBacklog); err != nil {
|
||||
ep.Close()
|
||||
return nil, &net.OpError{
|
||||
Op: "listen",
|
||||
|
||||
Reference in New Issue
Block a user