Uh oh!
There was an error while loading. Please reload this page.
Set of offset-based APIs for thread-safe file IO - #53669
Conversation
…Helpers to SafeFileHandle itself
…le.OpenHandle to FileStreamHelpers
…omFile.ReadAtOffset are going to need it)
…s it's a Windows-specific concept
…Seek for regular files
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* with NtCreateFile there is no need for Validation (NtCreateFile returns error and we never create a safe file handle) * unify status codes * complete error mapping
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Stephen Toub <stoub@microsoft.com>
| { | ||
| public byte* Base; | ||
| public UIntPtr Count; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| int64_t count = 0; | ||
| int fileDescriptor = ToFileDescriptor(fd); | ||
| #if HAVE_PREADV && !defined(TARGET_WASM) // preadv is buggy on WASM |
There was a problem hiding this comment.
Let's open an issue in runtime for now and include the link here.
| } ProcessStatus; | ||
| // NOTE: the layout of this type is intended to exactly match the layout of a `struct iovec`. There are | ||
| // assertions in pal_networking.c that validate this. |
There was a problem hiding this comment.
Should we move them to here?
runtime/src/libraries/Native/Unix/System.Native/pal_networking.c
Lines 163 to 168 in c87354c
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Stephen Toub <stoub@microsoft.com>
janvorli
commented
Jun 15, 2021
@adamsitnik this change has broken my local build on Apple Silicon. It fails with: However the checks for HAVE_PREADV and HAVE_PWRITEV in the configuration have succeeded. I suspect that the functions have moved to a different header file in recent SDK and the pal_io.c doesn't include it. But I am not sure yet. |
janvorli
commented
Jun 15, 2021
Btw, this was a clean build after git clean -xdf. |
janvorli
commented
Jun 15, 2021
I can see that the preadv / pwritew in my SDK are available only if: |
Nevermind, I see you already checked the headers meanwhile. Also I realized that the Apple Silicon version may target macOS 11 as minimum (unlike the x64 one). |
janvorli
commented
Jun 15, 2021
Adding |
I've moved all the logic responsible for opening and initializing
SafeFileHandletoSafeFileHandle. A lot of duplicated code (mostly for initializingThreadPoolBinding) got removed. On Unix, it's also now much more clear how many syscalls we perform to just open a file.Other changes:
NtCreateFilefor cases whenpreallocationSizewas specified andCreateFileWwhen not, I've followed @JeremyKuhne suggestion and switched to usingNtCreateFileonly. This has simplified the code and provided some minor perf gain. I've discovered a bug in the previous implementation (related toDesiredAccess.DELETE) fixed it, and added a testfstat()to ensure that a given file is not a directory we can also determine whether a given file is seekable or not. This has removed one syscall for the initialization ofCanSeek.Fixes#24847
@carlossanlop@jozkee@stephentoub PTAL. Once this PR is merged, I would like to finally publish the .NET Blog post.
cc @alexbudmsft