diff options
author | Anna Henningsen <anna@addaleax.net> | 2020-01-17 00:12:07 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-01-19 00:24:54 +0300 |
commit | 7864c53629b11d69746a4fc1f041900eeb358d31 (patch) | |
tree | 02005011a25ef6364166563cf9c78363181d5e6d /src/node_file.h | |
parent | cc0748f509140b7b42d157348300a5581db98a37 (diff) |
fs: unset FileHandle fd after close
- Do not set the fd as a property on the native object.
- Use the already-existent `GetFD()` method to pass the
fd from C++ to JS.
- Cache the fd in JS to avoid repeated accesses to the
C++ getter.
- Set the fd to `-1` after close, thus reliably making
subsequent calls using the `FileHandle` return `EBADF`.
Fixes: https://github.com/nodejs/node/issues/31361
PR-URL: https://github.com/nodejs/node/pull/31389
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_file.h')
-rw-r--r-- | src/node_file.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/node_file.h b/src/node_file.h index 1042baaf8f7..0574aa8f6c0 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -205,7 +205,7 @@ class FileHandle final : public AsyncWrap, public StreamBase { static void New(const v8::FunctionCallbackInfo<v8::Value>& args); - int fd() const { return fd_; } + int GetFD() override { return fd_; } // Will asynchronously close the FD and return a Promise that will // be resolved once closing is complete. |