Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SO_REUSEPORT_LB on FreeBSD #106

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions control_freebsd.go
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
}
7 changes: 5 additions & 2 deletions control_unix.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the changes except for the change in build flags are needed here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah..right, Thanks for your patience man.
Needed a lot of handholding for this one .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. The fact that I have to approve CI every time makes things more complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one thing i wanted to find out, can't this be left to run automatically?
Would save your time and turn-around time for public contributors as well, because if there are any issues we can fix them based on CI failures itself.

Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
//go:build !plan9 && !windows && !wasm
//go:build !plan9 && !windows && !wasm && !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
}

Check warning on line 20 in control_unix.go

View check run for this annotation

Codecov / codecov/patch

control_unix.go#L19-L20

Added lines #L19 - L20 were not covered by tests
})
if controlErr != nil {
err = controlErr
Expand Down
Loading