-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
net: add fd protection, fix #3604 #3605
Conversation
stream.on('error', function() {}); | ||
stream.write('might crash'); | ||
} catch(e) {} | ||
}); // Should not crash. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test isn't durable enough; see #3604 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead wrap this in assert.throws()
to check that it both doesn't abort and that it throws properly. CI should be able to give us a better idea whether the test will work on all platforms.
Maybe someone with more knowledge can help come up with a better test? |
bool ret = false; | ||
|
||
if (fd >= 0 && | ||
(unsigned)fd < loop->nwatchers && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no C-style casts.
left few comments. |
b2041cf
to
e72c094
Compare
@trevnorris Thanks for reviewing! I have revised the commit according to your advice. |
bool ret = false; | ||
|
||
if (static_cast<unsigned>(fd) < loop->nwatchers && | ||
loop->watchers[fd] != NULL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loop->watchers
and loop->nwatchers
are UNIX-specific. This won't compile on Windows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And considered "private", so code should access them really...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case this job had better be handled by libuv
Any reason to keep this open? |
Nope, I'd move to close. |
This is one possible way to fix #3604