Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(iroh, iroh-relay): JoinSet disabling in tokio::select! #3052

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iroh-relay/src/quic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub(crate) mod server {
_ = cancel_accept_loop.cancelled() => {
break;
}
Some(res) = set.join_next(), if !set.is_empty() => {
Some(res) = set.join_next() => {
if let Err(err) = res {
if err.is_panic() {
panic!("task panicked: {err:#?}");
Expand Down
6 changes: 3 additions & 3 deletions iroh-relay/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ async fn relay_supervisor(
};
let res = tokio::select! {
biased;
ret = tasks.join_next(), if !tasks.is_empty() => ret.expect("checked"),
Some(ret) = tasks.join_next() => ret,
ret = &mut quic_fut, if quic_enabled => ret.map(anyhow::Ok),
ret = &mut relay_fut, if relay_enabled => ret.map(anyhow::Ok),
else => Ok(Err(anyhow!("No relay services are enabled."))),
Expand Down Expand Up @@ -547,7 +547,7 @@ async fn server_stun_listener(sock: UdpSocket) -> Result<()> {
tokio::select! {
biased;

Some(res) = tasks.join_next(), if !tasks.is_empty() => {
Some(res) = tasks.join_next() => {
if let Err(err) = res {
if err.is_panic() {
panic!("task panicked: {:#?}", err);
Expand Down Expand Up @@ -695,7 +695,7 @@ async fn run_captive_portal_service(http_listener: TcpListener) -> Result<()> {
tokio::select! {
biased;

Some(res) = tasks.join_next(), if !tasks.is_empty() => {
Some(res) = tasks.join_next() => {
if let Err(err) = res {
if err.is_panic() {
panic!("task panicked: {:#?}", err);
Expand Down
2 changes: 1 addition & 1 deletion iroh-relay/src/server/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl ServerBuilder {
_ = cancel.cancelled() => {
break;
}
Some(res) = set.join_next(), if !set.is_empty() => {
Some(res) = set.join_next() => {
if let Err(err) = res {
if err.is_panic() {
panic!("task panicked: {:#?}", err);
Expand Down
9 changes: 4 additions & 5 deletions iroh/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ impl RouterBuilder {
break;
},
// handle task terminations and quit on panics.
res = join_set.join_next(), if !join_set.is_empty() => {
Some(res) = join_set.join_next() => {
match res {
Some(Err(outer)) => {
Err(outer) => {
if outer.is_panic() {
error!("Task panicked: {outer:?}");
break;
Expand All @@ -277,13 +277,12 @@ impl RouterBuilder {
break;
}
}
Some(Ok(Some(()))) => {
Ok(Some(())) => {
trace!("Task finished");
}
Some(Ok(None)) => {
Ok(None) => {
trace!("Task cancelled");
}
_ => {}
}
},

Expand Down
Loading