Skip to content

Commit

Permalink
core: Use SO_REUSEPORT_LB on FreeBSD (#5554)
Browse files Browse the repository at this point in the history
to balance load between threads.
  • Loading branch information
jpds committed May 23, 2023
1 parent cee4441 commit 942fbb3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion listen_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func reusePort(network, address string, conn syscall.RawConn) error {
return nil
}
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",
zap.String("network", network),
zap.String("address", address),
Expand Down
7 changes: 7 additions & 0 deletions listen_unix_setopt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build unix && !freebsd

package caddy

import "golang.org/x/sys/unix"

const unixSOREUSEPORT = unix.SO_REUSEPORT
7 changes: 7 additions & 0 deletions listen_unix_setopt_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build freebsd

package caddy

import "golang.org/x/sys/unix"

const unixSOREUSEPORT = unix.SO_REUSEPORT_LB

0 comments on commit 942fbb3

Please sign in to comment.