Skip to content
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

Buffered file stream doesn't flush data right #77373

Closed
emayevski opened this issue Oct 24, 2022 · 5 comments · Fixed by #77384
Closed

Buffered file stream doesn't flush data right #77373

emayevski opened this issue Oct 24, 2022 · 5 comments · Fixed by #77384
Assignees
Milestone

Comments

@emayevski
Copy link

Description

In BufferedFileStreamStrategy.cs, the Flush(bool flushToDisk) method does not perform flushing to disk when flushToDisk == true and there is data in the read or write buffer. I.e., both conditional blocks marked as "// Has write data ..." and "// Has read data ... " return without calling the underlying strategy's flush(flushToDisk).

Reproduction Steps

No simple reproduction is available but the problem is obvious from the method itself.

Expected behavior

The underlying strategy's flush(flushToDisk) must be called in all cases.

Actual behavior

As described above.

Regression?

No response

Known Workarounds

Setting the buffer size to 0 causes no buffering and correct flushing. But this is not really a workaround since it requires disabling of buffering.

Configuration

.NET 6.

Other information

No response

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Oct 24, 2022
@emayevski
Copy link
Author

This belongs to area-System.IO

@ghost
Copy link

ghost commented Oct 24, 2022

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

In BufferedFileStreamStrategy.cs, the Flush(bool flushToDisk) method does not perform flushing to disk when flushToDisk == true and there is data in the read or write buffer. I.e., both conditional blocks marked as "// Has write data ..." and "// Has read data ... " return without calling the underlying strategy's flush(flushToDisk).

Reproduction Steps

No simple reproduction is available but the problem is obvious from the method itself.

Expected behavior

The underlying strategy's flush(flushToDisk) must be called in all cases.

Actual behavior

As described above.

Regression?

No response

Known Workarounds

Setting the buffer size to 0 causes no buffering and correct flushing. But this is not really a workaround since it requires disabling of buffering.

Configuration

.NET 6.

Other information

No response

Author: emayevski
Assignees: -
Labels:

area-System.IO, untriaged

Milestone: -

@adamsitnik adamsitnik self-assigned this Oct 24, 2022
@adamsitnik adamsitnik removed the untriaged New issue has not been triaged by the area owner label Oct 24, 2022
@adamsitnik adamsitnik added this to the 8.0.0 milestone Oct 24, 2022
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Oct 24, 2022
@adamsitnik
Copy link
Member

Hi @emayevski

Big thanks for a detailed bug report! I've sent a fix: #77384

Setting the buffer size to 0 causes no buffering and correct flushing. But this is not really a workaround since it requires disabling of buffering.

Another workaround is to call this this method twice (I know it's dirty).

@emayevski
Copy link
Author

Thank you!

The workaround is good too :).

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Oct 26, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants