-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Move the Windows remove_dir_all impl into a module and make it more race resistant #129800
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
Conversation
This comment has been minimized.
This comment has been minimized.
5fa0843
to
2ab3c15
Compare
2ab3c15
to
bb9d5c4
Compare
This PR modifies cc @jieyouxu |
I've enabled the test so I'll make extra sure it works in CI. @bors try |
Move the Windows remove_dir_all impl into a module and make it more race resistant This attempts to make the Windows implementation of `remove_dir_all` easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls to `remove_dir_all` running concurrently). The module level comment explains the issue. try-job: x86_64-msvc try-job: i686-msvc
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
fca4020
to
3b6f0ec
Compare
@bors try |
Move the Windows remove_dir_all impl into a module and make it more race resistant This attempts to make the Windows implementation of `remove_dir_all` easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls to `remove_dir_all` running concurrently). The module level comment explains the issue.
☀️ Try build successful - checks-actions |
oops, I was trying linux. Let's do that again... @bors try |
Move the Windows remove_dir_all impl into a module and make it more race resistant This attempts to make the Windows implementation of `remove_dir_all` easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls to `remove_dir_all` running concurrently). The module level comment explains the issue. try-job: x86_64-msvc try-job: i686-msvc
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
3b6f0ec
to
bb9d5c4
Compare
Ok, I'm going to give up on enabling the test for now. Given existing CI issues, I fear it's going to be a bit flaky no matter what. |
fn delete(parent: &File, name: &[u16]) -> Result<(), WinError> { | ||
// Note that the `delete` function consumes the opened file to ensure it's | ||
// dropped immediately. See module comments for why this is important. | ||
match open_link_no_reparse(parent, name, c::SYNCHRONIZE | c::DELETE) { |
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.
Can't we just use NtDeleteFile
here and avoid having to temporarily open the file? Would this avoid the ERROR_DELETE_PENDING
case?
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.
NtDeleteFile
has a couple of issues:
- the file isn't deleted until every handle to it is closed, system wide
- it doesn't delete files that have the readonly attribute set (which, for example, git makes heavy use of)
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#129152 (custom/external clippy support for bootstrapping) - rust-lang#129311 (don't copy `.rustc-dev-contents` from CI rustc) - rust-lang#129800 (Move the Windows remove_dir_all impl into a module and make it more race resistant) - rust-lang#129860 (update `object` dependency to remove duplicate `wasmparser`) - rust-lang#129885 (chore: remove repetitive words) - rust-lang#129913 (Add missing read_buf stub for x86_64-unknown-l4re-uclibc) - rust-lang#129916 (process.rs: remove "Basic usage" text where not useful) - rust-lang#129917 (Fix parsing of beta version in dry-run mode) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#129800 - ChrisDenton:remove-dir-all2, r=Amanieu Move the Windows remove_dir_all impl into a module and make it more race resistant This attempts to make the Windows implementation of `remove_dir_all` easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls to `remove_dir_all` running concurrently). The module level comment explains the issue. try-job: x86_64-msvc try-job: i686-msvc
…nieu Win: Open dir for sync access in remove_dir_all A small follow up to rust-lang#129800. We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
…nieu Win: Open dir for sync access in remove_dir_all A small follow up to rust-lang#129800. We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
Rollup merge of rust-lang#129934 - ChrisDenton:remove-dir-all3, r=Amanieu Win: Open dir for sync access in remove_dir_all A small follow up to rust-lang#129800. We should explicitly open directories for synchronous access. We ultimately use `GetFileInformationByHandleEx` to read directories which should paper over any issues caused by using async directory reads (or else return an error) but it's better to do the right thing in the first place. Note though that `delete` does not read or write any data so it's not necessary there.
This attempts to make the Windows implementation of
remove_dir_all
easier to understand and work with by separating out different concerns into their own functions. The code is mostly the same as before just moved around. There are some changes to make it more robust against races (e.g. two calls toremove_dir_all
running concurrently). The module level comment explains the issue.try-job: x86_64-msvc
try-job: i686-msvc