Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
Improves error handling.
  • Loading branch information
Aeron committed Mar 3, 2024
1 parent 3b60df6 commit 5dfa03c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include = ["src/**/*", "LICENSE", "README.md"]
edition = "2021"

[dependencies]
anyhow = { version = "1.0.80" }
async-std = { version = "1.12", features = ["attributes"] }
async-signals = { version = "0.4" }
clap = { version = "4.0", features = ["cargo", "derive", "env", "wrap_help"] }
Expand Down
4 changes: 3 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ mod pool;

use std::time::{Duration, Instant};

use anyhow::{bail, Result};
use async_signals::Signals;
use async_std::io::ErrorKind;
use async_std::net::TcpListener;
Expand All @@ -27,7 +28,7 @@ async fn process(
pool: ConnectionPoolProxy,
length: usize,
delay: Duration,
) -> Result<(SocketAddr, Duration), std::io::Error> {
) -> Result<(SocketAddr, Duration)> {
let addr = stream.peer_addr()?;
let cap = length + CRLF.len();
let now = Instant::now();
Expand Down Expand Up @@ -56,6 +57,7 @@ async fn process(
}
} else {
stream.shutdown(Shutdown::Both)?;
bail!("pool is not ready");
}

pool.remove(addr).await;
Expand Down

0 comments on commit 5dfa03c

Please sign in to comment.