Skip to content

Commit ef3645e

Browse files
authored
fix(iroh): Don't cause re-stuns all the time in browsers (#3234)
## Description - Always return `false` in `want_call_me_maybe` in browsers, as we never actually want to send call me maybes, since there's no direct addresses we can put into these messages. - Fix the shutdown logging in magicsock. Redundant warning were printed on graceful shutdown, and one was skipped in non-graceful shutdown. ## Notes & open questions Closes #3232 ## Change checklist <!-- Remove any that are not relevant. --> - [x] Self-review.
1 parent f09c89e commit ef3645e

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

iroh/src/magicsock.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,16 @@ impl Handle {
19131913
}
19141914
})
19151915
.await;
1916-
if shutdown_done.is_ok() {
1917-
warn!("tasks shutdown complete");
1918-
// shutdown all tasks
1919-
warn!("aborting remaining {}/3 tasks", tasks.len());
1920-
tasks.shutdown().await;
1916+
match shutdown_done {
1917+
Ok(_) => trace!("tasks finished in time, shutdown complete"),
1918+
Err(_elapsed) => {
1919+
// shutdown all tasks
1920+
warn!(
1921+
"tasks didn't finish in time, aborting remaining {}/3 tasks",
1922+
tasks.len()
1923+
);
1924+
tasks.shutdown().await;
1925+
}
19211926
}
19221927
trace!("magicsock closed");
19231928
}

iroh/src/magicsock/node_map/node_state.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ impl NodeState {
387387
///
388388
/// When a call-me-maybe message is sent we also need to send pings to all known paths
389389
/// of the endpoint. The [`NodeState::send_call_me_maybe`] function takes care of this.
390+
#[cfg(not(wasm_browser))]
390391
#[instrument("want_call_me_maybe", skip_all)]
391392
fn want_call_me_maybe(&self, now: &Instant) -> bool {
392393
trace!("full ping: wanted?");
@@ -418,6 +419,12 @@ impl NodeState {
418419
}
419420
}
420421

422+
#[cfg(wasm_browser)]
423+
fn want_call_me_maybe(&self, _now: &Instant) -> bool {
424+
trace!("full ping: skipped in browser");
425+
false
426+
}
427+
421428
/// Cleanup the expired ping for the passed in txid.
422429
#[instrument("disco", skip_all, fields(node = %self.node_id.fmt_short()))]
423430
pub(super) fn ping_timeout(&mut self, txid: stun::TransactionId) {

0 commit comments

Comments
 (0)