-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
unix,stream: fix getting the correct fd for a handle #6838
Conversation
This is the test case that does not work as expected with node 4.x and 5.x on Mac:
|
Can we translate that into an actual test to prevent regressions? |
Also, bonus nachos: we're no longer relying on libuv internals to get the fd. |
I'm not sure. It would be a OSX only test, which only works if we replaced the fd in the select trick. This could change over time if Apple fixes kqueue to support other fds. An alternate title would be along the lines of: "use official uv API instead of internal structures". |
Because it's a tty test it's more difficult to automate. Spawning, piping and redirecting change the code path within node and libuv pertaining to stdout and stderr. |
OK, well I did verify that the change worked on my OS X box, so LGTM. |
Nice. LGTM. A test would be good but can definitely understand the constraints. |
@@ -86,7 +86,7 @@ int StreamWrap::GetFD() { | |||
int fd = -1; | |||
#if !defined(_WIN32) | |||
if (stream() != nullptr) | |||
fd = stream()->io_watcher.fd; | |||
uv_fileno(reinterpret_cast<uv_handle_t*>(stream()), &fd); | |||
#endif |
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.
I think you might as well remove the #if !defined(_WIN32)
guard now.
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.
On Windows that's a HANDLE*
, and while it can be cast to an int
because only 32 bits are used AFAIS, I wasn't sure if we wanted to expose that.
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.
Good point. Let's leave it like this, then.
FWIW, dtruss on Mac showed that node 4.x and 5.x
|
LGTM |
On OSX it's possible that the fd is replaced, so use the proper libuv API to get the correct fd. PR-URL: nodejs#6753 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@saghul I didn't realize it at the time but we have similar logic in |
Oh, me neither. I'll make a PR later today if nobody beats me to it.
|
Refs: nodejs#6838 PR-URL: nodejs#6908 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@Fishrock123 patch applies cleanly to |
Refs: nodejs#6838 PR-URL: nodejs#6908 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
@saghul is this at all specific to v1.9.0? |
Refs: nodejs#6838 PR-URL: nodejs#6908 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Affected core subsystem(s)
stream
Description of change
On OSX it's possible that the fd is replaced, so use the proper libuv
API to get the correct fd.