-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
Some systems, for example Hurd doesn't support SO_REUSEADDR.
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.
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) |
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.
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] |
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.
Use errno_from_exception
instead of e.args[0]
everywhere.
- Don't swallow errors from SO_REUSEPORT since it's opt-in. - Use errno_from_exception. - Add comments
I'm taking over this change in #2392. |
- Don't swallow errors from SO_REUSEPORT since it's opt-in. - Use errno_from_exception.
Some systems, for example Hurd doesn't support SO_REUSEADDR.