Log error on SO_REUSEPORT and continue
The underlying system might not support
SO_REUSEPORT, even though it is available in
kernel 3.9+. If there's an error, continue.
@@ -8,19 +8,17 @@ import (
"net"
"syscall"
+ "github.com/coredns/coredns/plugin/pkg/log"
"golang.org/x/sys/unix"
)
-const supportsReusePort = true
-
-func reuseportControl(network, address string, c syscall.RawConn) (opErr error) {
- err := c.Control(func(fd uintptr) {
- opErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
- })
- if err != nil {
- return err
+func reuseportControl(network, address string, c syscall.RawConn) error {
+ c.Control(func(fd uintptr) {
+ if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
+ log.Warningf("Failed to set SO_REUSEPORT on socket: %s", err)
}
- return opErr
+ })
+ return nil
}
func listen(network, addr string) (net.Listener, error) {
