From 879f7fa1761061065459bb646f0400c04da36aed Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sat, 27 Jul 2024 22:34:43 +0200 Subject: [PATCH 1/2] IoLoop: rewrite should_continue condition This makes it way more readable. Also, we now make sure that we properly continue writing to the TCP stream if w have pending writes and it's not in error. This enables us not to leave promises behind and properly answering to a rabbitmq server's connection.close with a connection.close-ok. Fixes #413 Properly fixes #409 Signed-off-by: Marc-Antoine Perennou --- src/io_loop.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/io_loop.rs b/src/io_loop.rs index 9c1e7e64..abd7d5a3 100644 --- a/src/io_loop.rs +++ b/src/io_loop.rs @@ -145,11 +145,15 @@ impl IoLoop { } fn should_continue(&self) -> bool { - (self.status != Status::Connected - || self.connection_status.connected() - || self.connection_status.closing()) - && self.status != Status::Stop - && !self.connection_status.errored() + match self.status { + Status::Initial => !self.connection_status.errored(), + Status::Stop => false, + Status::Connected => { + self.connection_status.connected() + || self.connection_status.closing() + || !self.serialized_frames.is_empty() + } + } } pub fn start(mut self) -> Result<()> { @@ -259,6 +263,7 @@ impl IoLoop { fn clear_serialized_frames(&mut self, error: Error) { for (_, resolver) in std::mem::take(&mut self.serialized_frames) { if let Some(resolver) = resolver { + trace!("We're quitting but had leftover frames, tag them as 'not sent' with current error"); resolver.swear(Err(error.clone())); } } From 6abb10107d6728865b56e1aa909668cebd619457 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sat, 27 Jul 2024 22:52:46 +0200 Subject: [PATCH 2/2] v2.5.0 Signed-off-by: Marc-Antoine Perennou --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd55816e..edb937f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### 2.5.0 (2024-07-27) + +#### Bug Fixes + +* Better handle in flight frames on io loop termination. + ### 2.4.0 (2024-07-16) #### Bug Fixes diff --git a/Cargo.toml b/Cargo.toml index ee14aab6..7c11e928 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lapin" -version = "2.4.0" +version = "2.5.0" edition = "2021" authors = ["Geoffroy Couprie ", "Marc-Antoine Perennou "] description = "AMQP client library"