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

Ignore ENOPROTOOPT errors from SO_REUSEADDR or SO_ERROR #2353

Closed
wants to merge 1 commit into from

Conversation

onovy
Copy link
Contributor

@onovy onovy commented Apr 11, 2018

Some systems, for example Hurd doesn't support SO_REUSEADDR.

Some systems, for example Hurd doesn't support SO_REUSEADDR.
Copy link
Member

@bdarnell bdarnell left a comment

Choose a reason for hiding this comment

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

Not supporting SO_ERROR on local sockets just seems like a gratuitous incompatibility on hurd's part, but I guess there's nothing we can do about that. Might be worth a comment that this is for hurd compatibility.

if reuse_port:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should swallow the error for SO_REUSEPORT. This only happens if explicitly requested by the user, so if we can't do what they asked for we should raise the error.

try:
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
except socket.error as e:
err = e.args[0]
Copy link
Member

Choose a reason for hiding this comment

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

Use errno_from_exception instead of e.args[0] everywhere.

bdarnell added a commit to bdarnell/tornado that referenced this pull request May 19, 2018
- Don't swallow errors from SO_REUSEPORT since it's opt-in.
- Use errno_from_exception.
- Add comments
@bdarnell
Copy link
Member

I'm taking over this change in #2392.

bdarnell added a commit to bdarnell/tornado that referenced this pull request Nov 1, 2019
- Don't swallow errors from SO_REUSEPORT since it's opt-in.
- Use errno_from_exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants