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
Socket gets unlinked when children closes the socket file descriptor #16
Comments
Some more thoughts on this: The naive way to solve this would be to just wrap This will probably work with the However, this falls short as soon as the child process is actively using the socket and it's closed in the parent, for example (in pseudocode): fd = socket(...);
pid = fork();
if (pid == 0) { // children
accept(fd, ...);
...
}
// parent
close(fd);
waitpid(pid, ...); In this case, the socket would be We could get around this by having a side-channel which keeps track of the processes using a socket controlled by us. One very error-prone, non-portable and racy way would be by checking Both however doesn't sound like the right solution here and I'd rather have a more simple solution where we even wouldn't need to wrap Another way would be to not |
I was trying to reproduce the bug reliably on centos:7 with
|
|
Comment moved to #23. |
While I haven't yet figured out how to properly solve this issue[1], let's at least provide a test case so that we can start experimenting with different solutions and quickly see whether it addresses the main issue or whether we need to get back to the drawing table. [1]: #16 Signed-off-by: aszlig <aszlig@nix.build>
Hi, I can report that I got bitten by this bug and the fix above works for me too. Please please consider adding a command-line switch to enable this behavior for users who need it! Leaking socket inodes is better than not working at all. Specifically, firefox has a low-level debugger protocol called "marionette" which only knows how to listen on TCP sockets. This is a lower-level and more powerful protocol than "chrome devtools" or "webdriver" (in fact, those are implemented using marionette). I don't want to leave such a powerful debugger interface to every random process on the same machine as the browser (including, potentially, website javascripts running inside the browser itself!) and ip2unix does a great job at that -- but it needs this patch. Details: https://bugzilla.mozilla.org/show_bug.cgi?id=1525126#c71 |
The issue is that adding a command line switch doesn't necessarily make the problem go away, because people do not necessarily know that they need such a switch, so I think we need to have a better interim solution. One that I could think of would be to Long-term however I think we need to switch to |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This is something that came up during a discussion[1] on how to solve our current socket cleanup issue: > Here is the case you can't handle: a server bind()s a socket, then > fork()s, and then accept()s in *both* the parent and child process > after the fork(). This is legitimate, and I'm sure somebody somewhere > is using it to get a crude form of multiprocess load-balancing. My point was that it doesn't matter in our case, but to make sure that I'm not missing something, I decided to add a test case to see whether my point is valid. [1]: #16 (comment) Signed-off-by: aszlig <aszlig@nix.build>
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Thank you! |
strace
output provided by @riedel in #13 (comment):My answer:
Originally posted by @aszlig in #13 (comment)
The text was updated successfully, but these errors were encountered: