mirror of
https://github.com/docker/cli.git
synced 2026-09-25 17:02:07 -04:00
- sockets: set socket permissions without overriding umask - sockets: improve abstract Unix socket handling - sockets: InmemSocket: add DialContext - sockets: remove double error decoration - sockets: test-enhancements and improve coverage full diff: https://github.com/docker/go-connections/compare/v0.7.0...v0.8.0 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
26 lines
593 B
Go
26 lines
593 B
Go
package sockets
|
|
|
|
import (
|
|
"os"
|
|
"strconv"
|
|
"strings"
|
|
"syscall"
|
|
)
|
|
|
|
// maxListenerBacklog returns the maximum length of the queue of pending
|
|
// connections for a listening socket.
|
|
//
|
|
// It is similar to in stdlib, but without the fallbacks for Kernel < 4.1.0;
|
|
// https://github.com/golang/go/blob/go1.26.3/src/net/sock_linux.go#L33-L53
|
|
func maxListenerBacklog() int {
|
|
b, err := os.ReadFile("/proc/sys/net/core/somaxconn")
|
|
if err != nil {
|
|
return syscall.SOMAXCONN
|
|
}
|
|
n, err := strconv.Atoi(strings.TrimSpace(string(b)))
|
|
if err != nil || n <= 0 {
|
|
return syscall.SOMAXCONN
|
|
}
|
|
return n
|
|
}
|