fs: add v8 fast api to closeSync#53627
Conversation
3d363dc to
734d1ba
Compare
734d1ba to
8354379
Compare
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.
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.
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.
I think I got it. Can you review it again? @joyeecheung
8354379 to
7b573d1
Compare
|
cc @nodejs/cpp-reviewers |
| } | ||
|
|
||
| void Environment::RemoveUnmanagedFd(int fd) { | ||
| void Environment::RemoveUnmanagedFd(int fd, bool schedule_native_immediate) { |
There was a problem hiding this comment.
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