Skip to content

Commit

Permalink
add size to ChannelError::BufferFull
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Feb 2, 2024
1 parent 5852c6b commit f9ac920
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions bin/src/ctl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions command/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -368,8 +368,8 @@ impl<Tx: Debug + ProstMessage + Default, Rx: Debug + ProstMessage + Default> 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,
Expand Down

0 comments on commit f9ac920

Please sign in to comment.