-
Notifications
You must be signed in to change notification settings - Fork 68
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
make Poller
fork-safe
#37
Comments
If this is agreeable, I can make an MR with this change, and add a test that |
This would need to be something that the user can choose, as the default needs to stay as it is right now. |
I don't believe the suggestion I'm making will change user-visible behavior, except when using
The change I suggest is to stop performing unneeded clean-up on file-descriptors that are about to be destroyed: Since they are about to be destroyed, the clean-up is unnecessary in the common case. In case I know that |
this sounds like the epoll fd should be created using |
|
oh. ah right, I think extracting the FD and forgetting the |
Interestingly, Boost ASIO has a |
that sounds a bit appealing (such a function would be marked |
Now that I think about it, a function like this would be far more relevant to |
We have an application in which we tried to use a
polling::Poller
in a parent process to accept a connection, thenfork
and handle the connection in the child process. (We aren't usingexec
, right now.) I discovered that this doesn't work well: after thefork
, when we tear down thePoller
structure, itsDrop
implementation removes thetimer_fd
andevent_fd
from theepoll_fd
. But because the file-descriptors (such as theepoll
file-descriptor thatPoller
uses internally) are shared between the parent process and the child process, this means that theepoll_fd
(which remains open in the parent process) gets into an invalid state. I'd like to close the files in the child, they aren't needed there, and I don't want to leak, but I'd like to avoid modifying theepoll_fd
while doing so.With this change:
I believe the implementation would be fork-safe, and slightly more performant.
The text was updated successfully, but these errors were encountered: