Skip to content

Commit

Permalink
Preserve send message state when flush is pending
Browse files Browse the repository at this point in the history
When the SendMessageState::Flush variant is active, we unconditionally
advance the state to Unused, even if the poll_flush_unpin() call returns
Pending. While unlikely to cause issues (because the flush will still go
through eventually), it seems more apt and in line with general future
workings to not advance the state and keep polling the flush until it
truly concluded.
  • Loading branch information
d-e-s-o committed Jan 3, 2024
1 parent 7c0da79 commit bf9390b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,16 @@ impl<M> SendMessageState<M> {
},
Self::Flush => {
trace!(channel = debug(sink as *const _), msg = "flushing");
*self = Self::Unused;
if let Poll::Ready(Err(err)) = sink.poll_flush_unpin(ctx) {
Err(err)
} else {
Ok(())
match sink.poll_flush_unpin(ctx) {
Poll::Pending => Ok(()),
Poll::Ready(Ok(())) => {
*self = Self::Unused;
Ok(())
},
Poll::Ready(Err(err)) => {
*self = Self::Unused;
Err(err)
},
}
},
}
Expand Down

0 comments on commit bf9390b

Please sign in to comment.