From f9ac9207df5edf4bad4e6c1392e829a3e1e080ed Mon Sep 17 00:00:00 2001 From: Emmanuel Bosquet Date: Wed, 6 Dec 2023 10:50:02 +0100 Subject: [PATCH] add size to ChannelError::BufferFull --- bin/src/ctl/mod.rs | 2 ++ command/src/channel.rs | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/src/ctl/mod.rs b/bin/src/ctl/mod.rs index 148f9081f..e7424efe5 100644 --- a/bin/src/ctl/mod.rs +++ b/bin/src/ctl/mod.rs @@ -73,6 +73,8 @@ pub fn ctl(args: cli::Args) -> Result<(), CtlError> { setup_logging_with_config(&config, "CTL"); } + debug!("started CLI with config: {:?}", config); + // If the command is `config check` then exit because if we are here, the configuration is valid if let SubCmd::Config { cmd: ConfigCmd::Check, diff --git a/command/src/channel.rs b/command/src/channel.rs index 3028f633b..755ada190 100644 --- a/command/src/channel.rs +++ b/command/src/channel.rs @@ -28,8 +28,8 @@ pub enum ChannelError { MessageTooLarge(usize), #[error("channel could not write on the back buffer")] Write(std::io::Error), - #[error("channel buffer is full, cannot grow more")] - BufferFull, + #[error("channel buffer is full ({0} bytes), cannot grow more")] + BufferFull(usize), #[error("Timeout is reached: {0:?}")] TimeoutReached(Duration), #[error("Could not read anything on the channel")] @@ -368,8 +368,8 @@ impl Cha } if self.front_buf.available_space() == 0 { - if (self.front_buf.capacity() as u64) == self.max_buffer_size { - return Err(ChannelError::BufferFull); + if (self.front_buf.capacity() as u64) >= self.max_buffer_size { + return Err(ChannelError::BufferFull(self.front_buf.capacity())); } let new_size = min( self.front_buf.capacity() + 5000,