mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-26 05:33:49 +03:00
core: Use SO_REUSEPORT_LB on FreeBSD (#5554)
to balance load between threads.
This commit is contained in:
parent
cee4441cb1
commit
942fbb37ec
3 changed files with 15 additions and 1 deletions
|
@ -119,7 +119,7 @@ func reusePort(network, address string, conn syscall.RawConn) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return conn.Control(func(descriptor uintptr) {
|
return conn.Control(func(descriptor uintptr) {
|
||||||
if err := unix.SetsockoptInt(int(descriptor), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil {
|
if err := unix.SetsockoptInt(int(descriptor), unix.SOL_SOCKET, unixSOREUSEPORT, 1); err != nil {
|
||||||
Log().Error("setting SO_REUSEPORT",
|
Log().Error("setting SO_REUSEPORT",
|
||||||
zap.String("network", network),
|
zap.String("network", network),
|
||||||
zap.String("address", address),
|
zap.String("address", address),
|
||||||
|
|
7
listen_unix_setopt.go
Normal file
7
listen_unix_setopt.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//go:build unix && !freebsd
|
||||||
|
|
||||||
|
package caddy
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
const unixSOREUSEPORT = unix.SO_REUSEPORT
|
7
listen_unix_setopt_freebsd.go
Normal file
7
listen_unix_setopt_freebsd.go
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
//go:build freebsd
|
||||||
|
|
||||||
|
package caddy
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
const unixSOREUSEPORT = unix.SO_REUSEPORT_LB
|
Loading…
Reference in a new issue