-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use SO_REUSEPORT_LB on FreeBSD (#106)
* feat: Add support for SO_REUSEPORT_LB option as per freeBSD * fix: address review comments * chore: updated to use build flags * chore: remove unnecessary code * chore: fix gofmt error
- Loading branch information
1 parent
0304740
commit 45f5681
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//go:build freebsd | ||
|
||
package reuseport | ||
|
||
import ( | ||
"syscall" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func Control(network, address string, c syscall.RawConn) (err error) { | ||
controlErr := c.Control(func(fd uintptr) { | ||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1) | ||
if err != nil { | ||
return | ||
} | ||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1) | ||
if err != nil { | ||
return | ||
} | ||
err = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT_LB, 1) | ||
}) | ||
if controlErr != nil { | ||
err = controlErr | ||
} | ||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
//go:build !plan9 && !windows && !wasm | ||
//go:build !plan9 && !windows && !wasm && !freebsd | ||
|
||
package reuseport | ||
|
||
|