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

doc: add note about fs.close undefined behavior #30966

Closed
wants to merge 6 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Dec 14, 2019

Basically what the close(2) man page says – if it’s possible that the fd is being used for a syscall in one thread of the threadpool, we should not be calling close() concurrently.

Refs: #30864

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Dec 14, 2019
@ronag
Copy link
Member Author

ronag commented Dec 14, 2019

@addaleax

doc/api/fs.md Outdated Show resolved Hide resolved
@ronag
Copy link
Member Author

ronag commented Dec 14, 2019

We might want to consider adding a ref count on fs ops and provide an unsafe version that does not do so (i.e. use at own risk but with better perf).

@ronag
Copy link
Member Author

ronag commented Dec 14, 2019

Is that disagreement or confusion on the previous comment?

@addaleax
Copy link
Member

@ronag It’s both … I feel like the suggestion misses a compelling reason to be implemented?

@ronag
Copy link
Member Author

ronag commented Dec 14, 2019

I feel like the suggestion misses a compelling reason to be implemented?

Consider the amount of users that are not aware of this quirk and are ending up unknowingly with code with undefined behaviour.

I'm also sceptical whether that's compelling enough. Probably isn't as bad in practice as I make it sound. Just thought it might be worth to consider.

doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with two small suggestions applied.

ronag and others added 2 commits December 15, 2019 01:22
Co-Authored-By: Rich Trott <rtrott@gmail.com>
Co-Authored-By: Rich Trott <rtrott@gmail.com>
@ronag
Copy link
Member Author

ronag commented Dec 15, 2019

Added note to closeSync as well.

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 15, 2019
@BridgeAR
Copy link
Member

doc/api/fs.md Outdated Show resolved Hide resolved
doc/api/fs.md Outdated Show resolved Hide resolved
Trott pushed a commit that referenced this pull request Dec 17, 2019
Add notes to fs.close and fs.closeSync() about udnefined behavior.

PR-URL: #30966
Refs: #30864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@Trott
Copy link
Member

Trott commented Dec 17, 2019

Landed in b376965

@Trott Trott closed this Dec 17, 2019
MylesBorins pushed a commit that referenced this pull request Dec 17, 2019
Add notes to fs.close and fs.closeSync() about udnefined behavior.

PR-URL: #30966
Refs: #30864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Dec 17, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
Add notes to fs.close and fs.closeSync() about udnefined behavior.

PR-URL: #30966
Refs: #30864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
Add notes to fs.close and fs.closeSync() about udnefined behavior.

PR-URL: #30966
Refs: #30864
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants