Skip to content

Commit

Permalink
Cleanup flush logic
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini authored and Jarema committed Sep 29, 2023
1 parent 4176419 commit 73e0aa2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
4 changes: 0 additions & 4 deletions async-nats/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,6 @@ impl Connection {
///
/// no-op if the write stream didn't need to be flushed.
pub(crate) fn poll_flush(&mut self, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
if !self.can_flush {
return Poll::Ready(Ok(()));
}

match Pin::new(&mut self.stream).poll_flush(cx) {
Poll::Pending => Poll::Pending,
Poll::Ready(Ok(())) => {
Expand Down
7 changes: 1 addition & 6 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,6 @@ impl ConnectionHandler {
Poll::Ready(ExitReason::Disconnected(None))
} else {
self.handler.connection.enqueue_write_op(&ClientOp::Ping);
self.handler.is_flushing = true;

Poll::Pending
}
Expand Down Expand Up @@ -484,11 +483,7 @@ impl ConnectionHandler {
}
}

if !self.handler.is_flushing && self.handler.connection.should_flush() {
self.handler.is_flushing = true;
}

if self.handler.is_flushing {
if self.handler.is_flushing || self.handler.connection.should_flush() {
match self.handler.connection.poll_flush(cx) {
Poll::Pending => {}
Poll::Ready(Ok(())) => {
Expand Down

0 comments on commit 73e0aa2

Please sign in to comment.