Files
podman/pkg/machine/ports/ports_unix.go
Paul Holzinger 5c1ed12d8d enable gofumpt formatter
Based on our discussion gofumpt won the vote so use that one via
golangci-lint.

https://github.com/containers/podman/discussions/27291

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-11-11 12:32:46 +01:00

29 lines
812 B
Go

//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
package ports
import (
"net"
"syscall"
)
func getPortCheckListenConfig() *net.ListenConfig {
return &net.ListenConfig{
Control: func(_, _ string, c syscall.RawConn) (cerr error) {
if err := c.Control(func(fd uintptr) {
// Prevent listening socket from holding over in TIME_WAIT in the rare case a connection
// attempt occurs in the short window the socket is listening. This ensures the registration
// will be gone when close() completes, freeing it up for the real subsequent listen by another
// process
cerr = syscall.SetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{
Onoff: 1,
Linger: 0,
})
}); err != nil {
cerr = err
}
return cerr
},
}
}