Skip to content

Commit

Permalink
fix ic_tee_logtail
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Nov 6, 2024
1 parent afb780e commit 63432a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 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 src/ic_tee_logtail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ license.workspace = true
tokio = { workspace = true }
anyhow = { workspace = true }
clap = { workspace = true }
log = { workspace = true }
16 changes: 8 additions & 8 deletions src/ic_tee_logtail/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ async fn main() -> Result<()> {
let listener = TcpListener::bind(&cli.ip_addr).await?;
println!("listening on {:?}", listener.local_addr()?);

loop {
match listener.accept().await {
Err(err) => println!("couldn't get client: {:?}", err),
Ok((mut stream, addr)) => {
println!("accept a client: {:?}", addr);
stream.readable().await?;
io::copy(&mut stream, &mut io::stdout()).await?;
while let Ok((mut stream, addr)) = listener.accept().await {
tokio::spawn(async move {
log::info!(target: "logtail", "accept a client: {:?}", addr);
let _ = stream.readable().await;
if let Err(err) = io::copy(&mut stream, &mut io::stdout()).await {
log::error!(target: "logtail", "error in transfer: {:?}", err);
}
}
});
}
Ok(())
}

0 comments on commit 63432a7

Please sign in to comment.