Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

linux: always deregister closing fds from epoll #1100

Closed
wants to merge 2 commits into from
Closed

linux: always deregister closing fds from epoll #1100

wants to merge 2 commits into from

Conversation

goffrie
Copy link
Contributor

@goffrie goffrie commented Feb 5, 2014

If the same file description is open in two different processes, then
closing the file descriptor is not sufficient to deregister it from the
epoll instance (as described in epoll(7)), resulting in spurious events
that cause the event loop to spin repeatedly. So always explicitly
deregister it.

Fixes #1099.

@Nodejs-Jenkins
Copy link

Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion.

The following commiters were not found in the CLA:

  • Geoffry Song

You can fix all these things without opening another issue.

Please see CONTRIBUTING.md for more information

*
* We pass in a dummy epoll_event, to work around a bug in old kernels.
*/
if (loop->backend_fd >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please omit braces here.

@indutny
Copy link
Contributor

indutny commented Feb 6, 2014

Thank you! LGTM, but it really needs to have a test.

Just FYI, the relevant files to introduce a new test:

@indutny
Copy link
Contributor

indutny commented Feb 6, 2014

@goffrie just thought that you may find this useful for implementing test: https://gist.github.com/indutny/8842007 . Anyway, if you don't feel like you want or have time to do it, let me know.

If the same file description is open in two different processes, then
closing the file descriptor is not sufficient to deregister it from the
epoll instance (as described in epoll(7)), resulting in spurious events
that cause the event loop to spin repeatedly. So always explicitly
deregister it.

Fixes #1099.
@goffrie
Copy link
Contributor Author

goffrie commented Feb 6, 2014

Alright, I fixed a little issue (return early-exit was messing things up) and added a test.


TEST_IMPL(closed_fd_events) {
/* spawn_helper4 blocks indefinitely. */
char *argv[] = { NULL, "spawn_helper4", NULL };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char* argv, not char *argv, please

@indutny
Copy link
Contributor

indutny commented Feb 6, 2014

Looks awesome! Thank you very much! Some style issue, but generally LGTM. I hope you'll agree with me that it would be simpler to have it in test-spawn.c, rather than in a separate file ;)

@goffrie
Copy link
Contributor Author

goffrie commented Feb 7, 2014

Alright, I've moved the test into test-spawn.c and made the style fixes you mentioned.

@indutny
Copy link
Contributor

indutny commented Feb 7, 2014

@goffrie looks totally good now! ;) Will land it with very minor style fixes that I'll make myself.

Could you please sign CLA to make me be able to push it to github?

@goffrie
Copy link
Contributor Author

goffrie commented Feb 12, 2014

Sorry for the delay -- I'm waiting for my employer to get back to me.

@indutny
Copy link
Contributor

indutny commented Feb 18, 2014

Hey man! Any news?

@goffrie
Copy link
Contributor Author

goffrie commented Feb 18, 2014

I've signed the CLA now. :)

@indutny
Copy link
Contributor

indutny commented Feb 19, 2014

Thank you, landed in 780d8ad

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants