Skip to content

Commit cb566ac

Browse files
committed
Clear buffer on write
1 parent 3841818 commit cb566ac

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/DotNext.IO/IO/PoolingBufferedStream.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public ValueTask WriteAsync(CancellationToken token = default)
222222
}
223223
else if (stream.CanWrite)
224224
{
225-
task = WriteCoreAsync(out _, token);
225+
task = WriteCoreAsync(token);
226226
}
227227
else
228228
{
@@ -232,6 +232,13 @@ public ValueTask WriteAsync(CancellationToken token = default)
232232
return task;
233233
}
234234

235+
private async ValueTask WriteCoreAsync(CancellationToken token)
236+
{
237+
await WriteCoreAsync(out var isWritten, token).ConfigureAwait(false);
238+
if (isWritten)
239+
Reset();
240+
}
241+
235242
private bool WriteCore()
236243
{
237244
Debug.Assert(stream is not null);

0 commit comments

Comments
 (0)