Skip to content

Commit

Permalink
fs: check closing_ in FileHandle::Close
Browse files Browse the repository at this point in the history
Fix possible flaky failure. Keep uv_fs_close from being called twice
on the same fd.

Refs: #39464
Signed-off-by: James M Snell <jasnell@gmail.com>
  • Loading branch information
jasnell committed Jul 20, 2021
1 parent ad5dc4c commit 71343ea
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ BaseObjectPtr<BaseObject> FileHandle::TransferData::Deserialize(
// JS during GC. If closing the fd fails at this point, a fatal exception
// will crash the process immediately.
inline void FileHandle::Close() {
if (closed_) return;
if (closed_ || closing_) return;
uv_fs_t req;
int ret = uv_fs_close(env()->event_loop(), &req, fd_, nullptr);
uv_fs_req_cleanup(&req);
Expand Down

0 comments on commit 71343ea

Please sign in to comment.