Skip to content
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

A way to pass a file descriptor to Node? #304

Closed
danielgindi opened this issue Jul 16, 2018 · 7 comments
Closed

A way to pass a file descriptor to Node? #304

danielgindi opened this issue Jul 16, 2018 · 7 comments

Comments

@danielgindi
Copy link

As compiling a NAPI module results in a library with a separate CRT, the state containing the FD table is different.
So if I have a situation where I have a HANDLE or an FD that I want to pass to Node - I find it problematic right now.
There's no API to accept a Windows' HANDLE, and no api to duplicate an FD into Node's namespace.

Anyone knows of a way to do that?

Thank you!

@danielgindi
Copy link
Author

Basically what I'm looking for is the inverse of uv_get_osfhandle

@bzoz
Copy link

bzoz commented Jul 18, 2018

Duplicate of nodejs/node#15433?

@bzoz
Copy link

bzoz commented Jul 18, 2018

i.e. are you looking for uv_open_osfhandle to get implemented?

@danielgindi
Copy link
Author

Exactly! uv_open_osfhandle...

@danielgindi
Copy link
Author

The thing is that the whole issue is about passing an fd across modules, which is not possible in most cases due to separate CRTs (even if you recompile node.exe with msvcrt.dll, you must compile against the same version...)

But if have a fd you can extract its HANDLE and pass it on to an exported uv_open_osfhandle function which will re-wrap it in its own CRT state.

So right now it's possible to get an FD from node and use it in a native addon, but not vice versa.

bzoz added a commit to JaneaSystems/libuv that referenced this issue Jul 19, 2018
Adds uv_open_osfhandle to complete uv_get_osfhandle

Ref: nodejs/node#15433
Ref: nodejs/node-addon-api#304
bzoz added a commit to JaneaSystems/libuv that referenced this issue Aug 1, 2018
Adds uv_open_osfhandle to complete uv_get_osfhandle

Ref: nodejs/node#15433
Ref: nodejs/node-addon-api#304
bzoz added a commit to libuv/libuv that referenced this issue Aug 9, 2018
Adds uv_open_osfhandle to complete uv_get_osfhandle

Ref: nodejs/node#15433
Ref: nodejs/node-addon-api#304
PR-URL: #1927
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
cjihrig added a commit to cjihrig/node that referenced this issue Aug 20, 2018
Notable changes:
- Restores compatibility with the old IPC protocol.
- Adds uv_open_osfhandle().
- Adds uv_os_{get,set}priority().

PR-URL: nodejs#22365
Fixes: nodejs#21671
Fixes: nodejs#15433
Refs: nodejs#21675
Refs: nodejs/node-addon-api#304
Refs: nodejs/abi-stable-node#318
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit to nodejs/node that referenced this issue Aug 21, 2018
Notable changes:
- Restores compatibility with the old IPC protocol.
- Adds uv_open_osfhandle().
- Adds uv_os_{get,set}priority().

PR-URL: #22365
Fixes: #21671
Fixes: #15433
Refs: #21675
Refs: nodejs/node-addon-api#304
Refs: nodejs/abi-stable-node#318
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit to nodejs/node that referenced this issue Sep 3, 2018
Notable changes:
- Restores compatibility with the old IPC protocol.
- Adds uv_open_osfhandle().
- Adds uv_os_{get,set}priority().

PR-URL: #22365
Fixes: #21671
Fixes: #15433
Refs: #21675
Refs: nodejs/node-addon-api#304
Refs: nodejs/abi-stable-node#318
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@bzoz
Copy link

bzoz commented Oct 11, 2018

Fixed by libuv/libuv#1927 included in nodejs/node#22365

@danielgindi
Copy link
Author

Yeah I already am enjoying this :-)

MylesBorins pushed a commit to MylesBorins/node that referenced this issue Nov 5, 2018
Notable changes:
- Restores compatibility with the old IPC protocol.
- Adds uv_open_osfhandle().
- Adds uv_os_{get,set}priority().

PR-URL: nodejs#22365
Fixes: nodejs#21671
Fixes: nodejs#15433
Refs: nodejs#21675
Refs: nodejs/node-addon-api#304
Refs: nodejs/abi-stable-node#318
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins pushed a commit to nodejs/node that referenced this issue Nov 11, 2018
Notable changes:
- Restores compatibility with the old IPC protocol.
- Adds uv_open_osfhandle().
- Adds uv_os_{get,set}priority().

Backport-PR-URL: #24103
PR-URL: #22365
Fixes: #21671
Fixes: #15433
Refs: #21675
Refs: nodejs/node-addon-api#304
Refs: nodejs/abi-stable-node#318
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants