mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-23 00:53:02 -05:00
flock mapped each call straight onto LockFileEx/UnlockFileEx, whose byte-range locks stack per handle. LOCK_UN without a lock failed with ERROR_NOT_LOCKED and aborted the process, a repeated LOCK_EX blocked forever, converting between shared and exclusive failed, and a repeated LOCK_SH needed as many unlocks. Track the one lock each descriptor holds: a repeated mode and LOCK_UN without a lock succeed, a conversion releases the old lock before taking the new one, and close forgets the descriptor's lock.