Skip to content

Commit 42d921f

Browse files
committed
fixup
1 parent 9b95365 commit 42d921f

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

src/actor.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -605,24 +605,27 @@ impl SyncHandle {
605605

606606
impl Drop for SyncHandle {
607607
fn drop(&mut self) {
608-
#[cfg(wasm_browser)]
609-
{
610-
let tx = self.tx.clone();
611-
n0_future::task::spawn(async move {
612-
tx.send(Action::Shutdown { reply: None }).await.ok();
613-
});
614-
}
615608
// this means we're dropping the last reference
616-
#[cfg(not(wasm_browser))]
609+
#[allow(unused)]
617610
if let Some(handle) = Arc::get_mut(&mut self.join_handle) {
618-
// this call is the reason tx can not be a tokio mpsc channel.
619-
// we have no control about where drop is called, yet tokio send_blocking panics
620-
// when called from inside a tokio runtime.
621-
self.tx.send_blocking(Action::Shutdown { reply: None }).ok();
622-
let handle = handle.take().expect("this can only run once");
623-
624-
if let Err(err) = handle.join() {
625-
warn!(?err, "Failed to join sync actor");
611+
#[cfg(wasm_browser)]
612+
{
613+
let tx = self.tx.clone();
614+
n0_future::task::spawn(async move {
615+
tx.send(Action::Shutdown { reply: None }).await.ok();
616+
});
617+
}
618+
#[cfg(not(wasm_browser))]
619+
{
620+
// this call is the reason tx can not be a tokio mpsc channel.
621+
// we have no control about where drop is called, yet tokio send_blocking panics
622+
// when called from inside a tokio runtime.
623+
self.tx.send_blocking(Action::Shutdown { reply: None }).ok();
624+
let handle = handle.take().expect("this can only run once");
625+
626+
if let Err(err) = handle.join() {
627+
warn!(?err, "Failed to join sync actor");
628+
}
626629
}
627630
}
628631
}

src/engine/gossip.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ use iroh_gossip::{
99
api::{Event, GossipReceiver, GossipSender, JoinOptions},
1010
net::Gossip,
1111
};
12-
use tokio::{
13-
sync::mpsc,
14-
task::{AbortHandle, JoinSet},
15-
};
12+
use n0_future::task::{AbortHandle, JoinSet};
13+
use tokio::sync::mpsc;
1614
use tracing::{debug, instrument, warn};
1715

1816
use super::live::{Op, ToLiveActor};

src/engine/live.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ use iroh_blobs::{
1919
Hash, HashAndFormat,
2020
};
2121
use iroh_gossip::net::Gossip;
22+
use n0_future::task::JoinSet;
2223
use n0_future::time::SystemTime;
2324
use serde::{Deserialize, Serialize};
24-
use tokio::{
25-
sync::{self, mpsc, oneshot},
26-
task::JoinSet,
27-
};
25+
use tokio::sync::{self, mpsc, oneshot};
2826
use tracing::{debug, error, info, instrument, trace, warn, Instrument, Span};
2927

3028
// use super::gossip::{GossipActor, ToGossipActor};

0 commit comments

Comments
 (0)