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

Read SO_REUSEPORT on socket before setting #803

Closed

Conversation

stuartnelson3
Copy link

See if we're able to read the value from the
socket. If that fails, skip setting the value on
the port.

Note: I don't have any machines with an old enough kernel lying around to test that it fails correctly, but perhaps someone out there could jump in and give it a try.

Given this comment: #802 (comment)
I'm not sure where you want this to live, or if it's on the user to know they can use SO_REUSEPORT or not.

See if we're able to read the value from the
socket. If that fails, skip setting the value on
the port.
@miekg
Copy link
Owner

miekg commented Oct 27, 2018

Might be simpler to always do this, instead of the conditional compilation? Would there be any downsides to that?

@codecov-io
Copy link

codecov-io commented Oct 27, 2018

Codecov Report

Merging #803 into master will decrease coverage by 0.06%.
The diff coverage is 25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #803      +/-   ##
==========================================
- Coverage   57.62%   57.56%   -0.07%     
==========================================
  Files          42       42              
  Lines       10856    10859       +3     
==========================================
- Hits         6256     6251       -5     
- Misses       3511     3517       +6     
- Partials     1089     1091       +2
Impacted Files Coverage Δ
listen_go111.go 66.66% <25%> (-11.12%) ⬇️
msg.go 77.7% <0%> (-0.65%) ⬇️
server.go 71.21% <0%> (-0.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 915ca3d...07c4266. Read the comment docs.

@stuartnelson3
Copy link
Author

Based on this comment: #654 (comment)

It sounds like this behavior is only supported in go1.11+?

_, err := unix.GetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT)
if err != nil {
opErr = fmt.Errorf("could not get SO_REUSEPORT: %s", err.Error())
return
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this explicitly return opErr?

@miekg
Copy link
Owner

miekg commented Oct 29, 2018 via email

@stuartnelson3
Copy link
Author

Closing, as users are allowed to opt-in to this code.

@stuartnelson3 stuartnelson3 deleted the stn/check-reuseport-support branch October 29, 2018 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants