From d2b9fbe3b2f1287ae7d0a2caa7befd008433236c Mon Sep 17 00:00:00 2001 From: Daniel Sockwell Date: Wed, 29 Apr 2020 17:10:58 -0400 Subject: [PATCH] Fix `channel full` codepath (#147) A bug was causing the buffer index to not properly update when handling full channels; this is now fixed. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/response/redis/manager.rs | 10 +++++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ec3f6cd..84de382 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -416,7 +416,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "flodgatt" -version = "0.9.7" +version = "0.9.8" dependencies = [ "criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "dotenv 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index f13c9ad..6ea405d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "flodgatt" description = "A blazingly fast drop-in replacement for the Mastodon streaming api server" -version = "0.9.7" +version = "0.9.8" authors = ["Daniel Long Sockwell "] edition = "2018" diff --git a/src/response/redis/manager.rs b/src/response/redis/manager.rs index 27ded0c..aaade1f 100644 --- a/src/response/redis/manager.rs +++ b/src/response/redis/manager.rs @@ -70,15 +70,18 @@ impl Stream for Manager { } } unread = msg.leftover_input; + self.unread_idx.0 = self.unread_idx.1 - unread.len(); + } + Ok(NonMsg(leftover_input)) => { + unread = leftover_input; + self.unread_idx.0 = self.unread_idx.1 - unread.len(); } - Ok(NonMsg(leftover_input)) => unread = leftover_input, Err(RedisParseErr::Incomplete) => { self.copy_partial_msg(); - unread = ""; + break; } Err(e) => Err(Error::RedisParseErr(e, unread.to_string()))?, }; - self.unread_idx.0 = self.unread_idx.1 - unread.len(); } if self.unread_idx.0 == self.unread_idx.1 { self.unread_idx = (0, 0) @@ -104,6 +107,7 @@ impl Manager { self.redis_conn.input = self.redis_conn.input[self.unread_idx.0..].into(); } self.unread_idx = (0, self.unread_idx.1 - self.unread_idx.0); + dbg!(&self.unread_idx); } /// Create a new `Manager`, with its own Redis connections (but no active subscriptions). pub fn try_from(redis_cfg: &config::Redis) -> Result {