-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle incomplete writes #55474
Handle incomplete writes #55474
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThis is a short term solution for #55473. It solves the problem, but only for I can't provide a better solution right now because I am on vacations. I'll be back in a week, then I can provide a long-term fix.
|
Span<byte> buffer = bytes; | ||
do | ||
{ | ||
int bytesWritten = RandomAccess.WriteAtOffset(sfh, buffer, offset); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this somehow handle !buffer.IsEmpty && bytesWritten == 0
to prevent infinite loop? (Logically, it would make more sense to me as a while
loop instead of do-while
loop).
#pragma warning restore CA2012 | ||
|
||
private ValueTask<int> WriteAsyncCore(ReadOnlyMemory<byte> source, CancellationToken cancellationToken) | ||
public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken) | |
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken) |
Thanks. #55490 provides the longer-term fix. |
This is a short term solution for #55473. It solves the problem, but only for
FileStream
and it's introducing a performance regression (allocations).I can't provide a better solution right now because I am on vacations. I'll be back in a week, then I can provide a long-term fix.