-
Notifications
You must be signed in to change notification settings - Fork 30k
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
fs: add v8 fast api to closeSync #53627
Conversation
3d363dc
to
734d1ba
Compare
734d1ba
to
8354379
Compare
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.
lgtm
src/node_file.cc
Outdated
options.fallback = true; | ||
} else { | ||
// Only remove unmanaged fds if the close was successful. | ||
env->RemoveUnmanagedFd(fd); |
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 is unsafe, RemoveUnmanagedFd()
can call ProcessEmitWarning()
which calls back into JS process.emitWarning()
and violates the fast API protocol. Although since it's just a warning, you could probably just add a parameter to RemoveUnmanagedFd
to make it invoke ProcessEmitWarning()
later in a native Immediate, and scheduling a native immediate is safe.
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.
If I understood you correctly, inside RemoveUnmanagedFd
you want me to conditionally call the following right?
SetImmediateThreadsafe([](Environment* env) {
ProcessEmitWarning(
this, "File descriptor %d closed but not opened in unmanaged mode", fd);
});
If not, what is the correct way to schedule a native immediate?
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 I got it. Can you review it again? @joyeecheung
8354379
to
7b573d1
Compare
cc @nodejs/cpp-reviewers |
@@ -1841,12 +1841,23 @@ void Environment::AddUnmanagedFd(int fd) { | |||
} | |||
} | |||
|
|||
void Environment::RemoveUnmanagedFd(int fd) { | |||
void Environment::RemoveUnmanagedFd(int fd, bool schedule_native_immediate) { |
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.
Not: generally not a fan of bool arguments like this. I prefer enums that allow the call sites to be clearer about what the argument is as opposed to just true or false.
Landed in ed6f45b |
PR-URL: #53627 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #53627 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#53627 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Vinícius Lourenço Claro Cardoso <[email protected]> Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: James M Snell <[email protected]>
Adds V8 Fast API to
fs.closeSync(fd)
implementationcc @nodejs/performance @nodejs/fs @nodejs/cpp-reviewers