Repository navigation
Record who holds a folder when its set-aside rename is refused on Windows - #611
Merged
Merged
Conversation
…used On Windows a refused rename names no one (os error 32 or 5). The record of set_aside_refused now carries the open handles the system lists on the folder or inside it, with the owning process and this process's id beside them, so a refusal says whether the holder is hided itself or another process. Refs #484
A handle of some kinds can block the questions the holder scan asks, so the scan no longer runs where the removal waits: it runs on its own thread, one at a time, and writes its own set_aside_holders line with the refusal's attempt id; a scan still running makes the next record scan_busy. The scan also duplicates only handles of the file object type, found from a file this process holds open, instead of every handle of every process. Refs #484
Spawned::Started carries the scan thread's JoinHandle, so a test joins it and then reads the slot rather than waiting on a count of yields. The product drops the handle. A system other than Windows no longer writes a holders line, since it has nothing to report. Refs #484
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #484
Summary
After #523's wait for the pane's processes, the worktree delete still fails on Windows now and then: the rename into
hide-removedis refused with os error 32, and the error names no one.This only adds to the log. When that rename is refused on Windows, a second line,
set_aside_holders(sameattemptasset_aside_refused), lists the open handles on the folder or inside it, with the owning process, the path, the access and this process's own id, so the next failure says whether the holder is hided or another process.Nothing on screen or in behavior changes: the refusal still falls back to Git's in-place removal as before, and the removal does not wait for the scan.
Review
hide-platform/src/fs/holders.rs- reads the system handle table (NtQuerySystemInformation) and duplicates only handles of the file object type (its number is read off a file this process holds open), still skipping the access masks of synchronous pipes; the one place withunsafe.hide-host/src/worktrees.rs-spawn_exclusiveandrecord_holders: the scan runs on its own thread, one at a time; the removal goes straight to Git's fallback and never waits. A blocked handle costs one thread and later records sayscan_busy; the slot is freed when the thread ends, a panic included.Mutex<Runtime>; one scan thread at most, at most 256 matches kept, table buffer capped at 256 MiB, andscan_msin the record shows the real cost.Evidence
the_process_holding_a_folder_or_a_file_in_it_is_listed_with_its_id) passed in theos contract (windows)lane: this process is listed for an open file inside a folder and for the open folder, and not once both are closed.holder_scan_tests(2): a scan that blocks holds the slot and nothing waits for it, a second call answers busy without running, a panicking scan frees the slot. The blocking itself is not reproduced with a real Windows handle: one that blocks cannot be arranged on a runner, so the test shows the property that matters, that the caller returns at once.