fix(windows): relax owned parent sharing before admission validation

This commit is contained in:
morluto committed 2026-10-15 08:35:11 +08:00
1 parent f15ddbea7a
commit db689f3c3c
1 file changed
+4 -2
+4 -2
View File
@@ -386,9 +386,11 @@ void createRuntime(const std::wstring& parentPath, const std::wstring& prefix,
owner->directory = createRelative(owner->parents.back().get(), name,
DELETE | FILE_LIST_DIRECTORY | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES | READ_CONTROL,
true, security, owner->path);
verifyPrivate(owner->directory.get(), owner->path, true);
// The owned child pins the parent nonempty before write sharing is relaxed.
// FILE_CREATE proves ownership and pins the parent nonempty independently
// of admission validation. A failed validation must not retain a strict
// parent lease that prevents renaming the still-owned child before retry.
owner->parents.back() = openComponent(parent->path, 0, true, FILE_SHARE_READ | FILE_SHARE_WRITE);
verifyPrivate(owner->directory.get(), owner->path, true);
} catch (Failure& primary) {
cleanupFailedRuntime(owner, primary);
throw;