Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle completed FlushResult on CopyToAsync#51147

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
davidfowl merged 3 commits intodotnet:mainfrommanandre:copy-pipe-complete
Apr 17, 2021

Conversation

@manandre
Copy link
Contributor


consumed=position;

if(flushResult.IsCompleted)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we have a test for this case? If youPipeReader.CopyToAsync(PipeWriter) and that pipe writer is complete before writing all of the data, and you copy the PipeReader to another Pipewriter and it resumes where it left off and continues copying.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I have added a test proposal. Comments are welcome.
I have checked that without the fix this test case hangs... as expected.
However, I have a doubt around the update of theconsumed position when the flush result is "completed". Indeed, by design, flush comes after write so data is considered as consumed (if not failed), but thePipe.WriteAsync method can return a completed FlushResult before consuming the provided data...
Do I miss something here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That's a really good point. Lets file another issue. There's basically no way to know if the data has been consumed or not. Great find!

manandre reacted with thumbs up emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You shouldn't have this check if you're doing other important stuff in this loop (which you are).

Copy link
Member

@halter73halter73Apr 16, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This was written during triage when we didn't have the full context yet. I've now read through most of the related issues.

It seems the problem is that when you have a PipeWriter/Reader pair with arbitrary Pause/ResumeThreshold,you cannot observe exactly when the read loop completed just using PipeWriter. This was already the case though. Checking FlushResult.IsCompleted doesn't change that. If anything, it helps you observe the read loop completed earlier than before.

You used by be able to usePipeWriter.OnReaderCompleted and a TCS for this, but that's been obsoleted. If we decide an API for this is important again, we'll want to directly expose aReaderCompletionTask or something like that anyway.

Edit: I see the issue is knowing where the read loop completed, not when. Does this matter? What scenario does PipeReader.CopyToAsync() complete successfully and the app tries to copy from the same, non-reset PipeReader again?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we leave this as it was the existing behavior. Assuming it was consumed.

halter73 reacted with thumbs up emoji
@davidfowldavidfowl merged commitf1bafe6 intodotnet:mainApr 17, 2021
@davidfowl
Copy link
Member

Thanks@manandre !

manandre reacted with thumbs up emoji

@manandremanandre deleted the copy-pipe-complete branchApril 17, 2021 08:17
manandre added a commit to manandre/runtime that referenced this pull requestMay 1, 2021
See disccussion indotnet#51147 (comment) and associated open issuedotnet#51272
@ghostghost locked asresolvedand limited conversation to collaboratorsMay 17, 2021
@karelzkarelz added this to the6.0.0 milestoneMay 20, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@davidfowldavidfowldavidfowl left review comments

@BrennanConroyBrennanConroyBrennanConroy left review comments

@halter73halter73halter73 approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

PipeReader CopyToAsync to a PipeWriter doesn't notice when the destination Pipe is closed.

5 participants

@manandre@davidfowl@halter73@BrennanConroy@karelz

[8]ページ先頭

©2009-2025 Movatter.jp