From 2574704710ce60a9196434e95d3a2322fc3dd823 Mon Sep 17 00:00:00 2001 From: lucifer9 Date: Mon, 23 Mar 2020 21:52:19 +0800 Subject: [PATCH] add SO_REUSEPORT for freebsd 11 --- transport/internet/sockopt_freebsd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transport/internet/sockopt_freebsd.go b/transport/internet/sockopt_freebsd.go index f99d37a9..46634cb6 100644 --- a/transport/internet/sockopt_freebsd.go +++ b/transport/internet/sockopt_freebsd.go @@ -35,6 +35,7 @@ type pfiocNatlook struct { const ( sizeofPfiocNatlook = 0x4c + soReUsePort = 0x00000200 soReUsePortLB = 0x00010000 ) @@ -192,7 +193,9 @@ func bindAddr(fd uintptr, ip []byte, port uint32) error { } if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, soReUsePortLB, 1); err != nil { - return newError("failed to set resuse_port").Base(err).AtWarning() + if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, soReUsePort, 1); err != nil { + return newError("failed to set resuse_port").Base(err).AtWarning() + } } var sockaddr syscall.Sockaddr