Log error on SO_REUSEPORT and continue (#2243)
The underlying system might not support SO_REUSEPORT, even though it is available in kernel 3.9+. If there's an error, continue. Signed-off-by: stuart nelson <stuartnelson3@gmail.com>
This commit is contained in:
parent
7b25d18019
commit
dc85f14e5c
1 changed files with 7 additions and 9 deletions
|
@ -8,19 +8,17 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/coredns/coredns/plugin/pkg/log"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const supportsReusePort = true
|
func reuseportControl(network, address string, c syscall.RawConn) error {
|
||||||
|
c.Control(func(fd uintptr) {
|
||||||
func reuseportControl(network, address string, c syscall.RawConn) (opErr error) {
|
if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
|
||||||
err := c.Control(func(fd uintptr) {
|
log.Warningf("Failed to set SO_REUSEPORT on socket: %s", err)
|
||||||
opErr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
return nil
|
||||||
return err
|
|
||||||
}
|
|
||||||
return opErr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func listen(network, addr string) (net.Listener, error) {
|
func listen(network, addr string) (net.Listener, error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue