-
Notifications
You must be signed in to change notification settings - Fork 735
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
Fix a number of potential fd leaks #1636
Fix a number of potential fd leaks #1636
Conversation
We do this by simply creating a fd-managing type, e.g. UnixDatagram, from the fd once it's created. Also first tries to parse the path as that can fail without doing a system call.
@Thomasdezeeuw |
I think new_socket should return OwnedFd or OwnedSocket or something. |
Can't, we support older Rust versions. |
So can we define our own OwnedFd or OwnedSocket? I feel that this is a bit against rust's deterministic release principle of resources. |
Looks reasonable to me. Is there any way to test this?
Immediately putting the file descriptor of the unix datagram into a |
If we can somehow trigger an error in binding/listening/connecting. But outside of binding every port I can't really think of a reasonable solution at the moment. |
Now all the fd creating code follows the following pattern. let raw_fd = create_fd(); let managed_fd = wrap(raw_fd); // Additional system calls return managed_fd
Do it in new_socket so that the higher levels don't have to worry about it.
Don't agree with the `&path` -> `path`, but it's fine.
I think the leakage scenario has been basically resolved. Can we consider solving the known issues first and redesigning this issue in the future to ensure that no new leakage occurs in the future? |
I don't think we'll need any further changes beyond this. What did you have in mind? |
No, thank you. |
We do this by simply creating a fd-managing types, e.g.
UnixDatagram
, from the fd once it's created.Also first tries to parse the path as that can fail without doing a system call.
Fixes #1635
/cc @silence-coding