mirror of
https://github.com/BepInEx/dotnet-runtime.git
synced 2026-11-22 19:10:41 -10:00
I'm trying to track down the cause of a sporadic failure in CI of the MemoryMappedFilesTests.DataShared test. In doing so, I've run across a few issues to be fixed (though I'm not sure any of these are the cause): - Fix the checking/setting of several FileOptions... we weren't correctly treating the options as a [Flags], which meant we'd incorrectly ignore some options if multiple options were specified. - When opening a FileStream, if the PosixFAdvise or SeekCore failed, we weren't deterministically disposing of the file handle, instead leaving it up to finalization to close. - If Close on the file descriptor fails (e.g. it's interrupted), we don't attempt a retry, by design. However, closing of the handle is what releases the advisory lock we placed on the file descriptor when the UnixFileStream was constructed. Added an explicit call to remove the lock, separate from closing the descriptor. (I thought this one would have been the cause of the sporadic test failure, but if it were the problem, the assert in SafeFileHandle.ReleaseHandle should have fired, and it didn't in the one occurence I saw since that assert got added.) - Removed several stale TODOs and replaced them with explanatory comments. - Added several more Debug.Asserts Separately, I also tweaked TempFile to simplify its ctor to use File.WriteAllBytes. Commit migrated from https://github.com/dotnet/corefx/commit/1e0cd691eee8bd65a3fed666ac4ea6a208a78b8c