-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Teach trio.socket.fromfd and friends to autodetect socket configuration on Linux #577
Conversation
There is problem with |
Codecov Report
@@ Coverage Diff @@
## master #577 +/- ##
=========================================
- Coverage 99.27% 97.1% -2.17%
=========================================
Files 89 89
Lines 10628 10656 +28
Branches 747 750 +3
=========================================
- Hits 10551 10348 -203
- Misses 59 274 +215
- Partials 18 34 +16
Continue to review full report at Codecov.
|
Hello! I'm afraid I have misled you and made this much more complicated than it has to be :-(. The code you used for a reference jumps through all kinds of hoops using ctypes, because it's trying to call So my suggestion would be to delete all the ctypes stuff, and instead have a function like this, that takes whatever the user gave us, fixes it up as best we can (which might be more or less depending on the OS), and returns the fixed up values. def _fix_attrs_for_fileno(family, type, proto, fileno):
# Wrap the raw fileno into a socket object
sockobj = _stdlib_socket.socket(fileno=fileno)
try:
if hasattr(socket, "SO_DOMAIN"):
family = sockobj.getsockopt(SOL_SOCKET, SO_DOMAIN)
if hasattr(socket, "SO_TYPE"):
type = sockobj.getsockopt(SOL_SOCKET, SO_TYPE)
if hasattr(socket, "SO_PROTOCOL"):
proto = sockobj.getsockopt(SOL_SOCKET, SO_PROTOCOL)
finally:
# Unwrap it again, so that sockobj.__del__ doesn't try to close our socket
sockobj.detach()
return family, type, proto And then in family, type, proto = _fix_attrs_for_fileno(family, type, proto, fileno) Does that make sense? |
@2easy Hey, just wanted to check in to see whether you're still interested in working on this :-) |
Sure thing, sorry for the delay. I'll fix it in the evening. |
Haven't heard anything for a week, so I'm going to close this for now to take it off the list of active PRs. Feel free to reopen it, or open a new PR, if you do decide to come back to it later! We've all been there :-) |
Hi, I'd like to propose this solution to the issue #251 .