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

Fix copy buffered write #4001

Merged
merged 5 commits into from
Jul 30, 2021
Merged

Conversation

quininer
Copy link
Member

Motivation

The current copy works poorly in some cases.
when reader output depends on writer and writer is buffered, a deadlock may occur.

see tokio-rs/tls#66

Solution

we can call flush when the reader is not progressing to prevent such deadlocks.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-io Module: tokio/io labels Jul 28, 2021
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

This implementation doesn't attempt to read while flushing, but maybe that should be part of #3694.

@quininer
Copy link
Member Author

Yes, there are two undecided decisions here.

  1. should flush block read?
  2. should flush block write?

I think it is good to have flush and read at same time, but I am not sure 2.
to be conservative, flush now blocks all operations.

@Darksonn
Copy link
Contributor

I would generally expect an IO resource to behave in a reasonable way if we stop flushing and starting writing again.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

This seems good to me.

@Darksonn Darksonn merged commit f516768 into tokio-rs:master Jul 30, 2021
@quininer quininer deleted the fix-copy-bufwrite branch July 30, 2021 09:23
@Darksonn Darksonn mentioned this pull request Aug 12, 2021
cfal added a commit to cfal/tobaru that referenced this pull request Aug 26, 2021
cfal added a commit to cfal/tobaru that referenced this pull request Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-io Module: tokio/io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants