From b8b1361a206d66e4a7afed8abbdd8054e3a59838 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Fri, 23 Feb 2018 20:54:05 +0100 Subject: [PATCH 1/2] Changed ping logic to eliminate a rare panic under heavy load (fixes #120). --- src/client/transport.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/client/transport.rs b/src/client/transport.rs index 938b3de..39dc2e5 100644 --- a/src/client/transport.rs +++ b/src/client/transport.rs @@ -69,12 +69,14 @@ where } fn send_ping(&mut self) -> error::Result<()> { - self.last_ping_sent = Instant::now(); - self.last_ping_data = format!("{}", Local::now().timestamp()); - let data = self.last_ping_data.clone(); + let last_ping_data = format!("{}", Local::now().timestamp()); + let data = last_ping_data.clone(); let result = self.start_send(Command::PING(data, None).into())?; - assert!(result.is_ready()); - self.poll_complete()?; + if let AsyncSink::Ready = result { + self.poll_complete()?; + self.last_ping_sent = Instant::now(); + self.last_ping_data = last_ping_data; + } Ok(()) } From ddd94de0d9bb0925280ecd4ca16e49bb0c99e198 Mon Sep 17 00:00:00 2001 From: Aaron Weiss Date: Fri, 23 Feb 2018 21:05:03 +0100 Subject: [PATCH 2/2] Bumped version to 0.13.4. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 52948c0..55e8e4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "irc" -version = "0.13.3" +version = "0.13.4" description = "A simple, thread-safe, and async-friendly library for IRC clients." authors = ["Aaron Weiss "] license = "MPL-2.0"