Skip to content

Commit

Permalink
exit immediately, do not handle accept failure
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Jun 16, 2022
1 parent 4289920 commit be7f9f0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
11 changes: 5 additions & 6 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions cmd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kaminari-cmd"
version = "0.5.3"
version = "0.5.4"
edition = "2021"
authors = ["zephyr <[email protected]>"]
repository = "https://github.com/zephyrchien/kaminari/cmd"
Expand All @@ -9,10 +9,10 @@ readme = "README.md"
license = "GPL-3.0"

[dependencies]
kaminari = "0.8.3"
realm_io = "0.3.2"
tokio = { version = "1", features = ["rt", "net", "macros"] }
anyhow = "1"
realm_io = "0.3.2"
kaminari = { version = "0.9.0", features = ["ws", "tls"] }
tokio = { version = "1.9", features = ["rt", "net", "macros"] }

[[bin]]
name = "kaminaric"
Expand Down
7 changes: 6 additions & 1 deletion cmd/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ async fn main() -> Result<()> {
Ok((stream, _)) => {
tokio::spawn(relay(stream, remote, $cc));
}
Err(e) => eprintln!("accept error: {}", e),
Err(e) => {
eprintln!("accept error: {}", e);
break;
}
}
}
};
Expand Down Expand Up @@ -87,6 +90,8 @@ async fn main() -> Result<()> {
run_ws_each!(client);
}
};

Ok(())
}

async fn relay<T>(mut local: TcpStream, remote: SocketAddr, client: Ref<T>) -> std::io::Result<()>
Expand Down
7 changes: 6 additions & 1 deletion cmd/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ async fn main() -> Result<()> {
Ok((stream, _)) => {
tokio::spawn(relay(stream, remote, $ac));
}
Err(e) => eprintln!("accept error: {}", e),
Err(e) => {
eprintln!("accept error: {}", e);
break;
}
}
}
};
Expand All @@ -75,6 +78,8 @@ async fn main() -> Result<()> {
run!(Ref::new(&server));
}
};

Ok(())
}

async fn relay<T: AsyncAccept<TcpStream>>(
Expand Down

0 comments on commit be7f9f0

Please sign in to comment.