-
Notifications
You must be signed in to change notification settings - Fork 108
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
Changes from 1 commit
e965df1
280dee2
b9a6708
2f99b77
82f33be
2f2c5e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,13 +8,20 @@ import ( | |
"golang.org/x/sys/unix" | ||
) | ||
|
||
// This value has been taken from https://reviews.freebsd.org/D11003 since this is not yet provided in golang. | ||
const FREEBSD_SO_REUSEPORT_LB = 0x00010000 | ||
chaitanyaprem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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, FREEBSD_SO_REUSEPORT_LB, 1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should only be executed on FreeBSD. We can't just set a random sock opt on other platforms. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it, I was thinking of making it future proof by having it for all unix systems. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This constant is only defined on FreeBSD. You'll need to use build flags. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done, tested on freeBSD and macOS after these changes. |
||
}) | ||
if controlErr != nil { | ||
err = controlErr | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 .
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.