Skip to content

Commit f221f5e

Browse files
committed
document the locking behavior a bit more
1 parent b36f036 commit f221f5e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cargo/core/compiler/locking.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ impl UnitLock {
114114

115115
// TODO: Add debug asserts to verify the lock state?
116116

117-
// We know we have an exclusive lock here so we should never block.
118-
// This is not super well documented but `lock_shared()` should downgrade the lock.
117+
// NOTE:
118+
// > Subsequent flock() calls on an already locked file will convert an existing lock to the new lock mode.
119+
// https://man7.org/linux/man-pages/man2/flock.2.html
120+
//
121+
// However, the `std::file::File::lock/lock_shared` is allowed to change this in the
122+
// future. So its probably up to us if we are okay with using this or if we want to use a
123+
// different interace to flock.
124+
//
119125
// TODO: Need to validate on other platforms...
120126
gaurd.primary.lock_shared().unwrap();
121127
}

0 commit comments

Comments
 (0)