Skip to content

Commit

Permalink
io: remove erroneous wake call in SinkWriter (#5436)
Browse files Browse the repository at this point in the history
  • Loading branch information
funbringer authored Feb 7, 2023
1 parent abf5d28 commit 5653b45
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions tokio-util/src/io/sink_writer.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use futures_core::ready;
use futures_sink::Sink;

use pin_project_lite::pin_project;
Expand Down Expand Up @@ -98,19 +99,11 @@ where
buf: &[u8],
) -> Poll<Result<usize, io::Error>> {
let mut this = self.project();
match this.inner.as_mut().poll_ready(cx) {
Poll::Ready(Ok(())) => {
if let Err(e) = this.inner.as_mut().start_send(buf) {
Poll::Ready(Err(e.into()))
} else {
Poll::Ready(Ok(buf.len()))
}
}
Poll::Ready(Err(e)) => Poll::Ready(Err(e.into())),
Poll::Pending => {
cx.waker().wake_by_ref();
Poll::Pending
}

ready!(this.inner.as_mut().poll_ready(cx).map_err(Into::into))?;
match this.inner.as_mut().start_send(buf) {
Ok(()) => Poll::Ready(Ok(buf.len())),
Err(e) => Poll::Ready(Err(e.into())),
}
}

Expand Down

0 comments on commit 5653b45

Please sign in to comment.