Skip to content

Commit

Permalink
Revert (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mobile-bungalow authored Feb 17, 2025
1 parent 96eb16b commit 3c43e80
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
31 changes: 0 additions & 31 deletions src/ffi/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,37 +462,6 @@ impl Channel {
}
}

impl Drop for Channel {
fn drop(&mut self) {
let sender = self.state_command_tx.clone();
let handle = self.join_handle.take();
let topic = self.topic.to_string();

tokio::spawn(async move {
let (left_tx, left_rx) = oneshot::channel();

let Some(handle) = handle else {
return;
};

if sender.send(StateCommand::Leave { left_tx }).await.is_ok() {
match left_rx.await {
Ok(Err(e)) => {
error!("Error leaving channel {topic} on drop: {e}");
}
Err(_) => {}
_ => {}
};

// the only errors are if the task is aslready shut down
let _ = handle.await;
} else {
handle.abort()
}
});
}
}

/// Errors when calling [Channel::join].
#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error, uniffi::Error)]
pub enum ChannelJoinError {
Expand Down
21 changes: 0 additions & 21 deletions src/ffi/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
//! # }
use atomic_take::AtomicTake;
use log::error;
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use tokio::sync::{mpsc, oneshot};
Expand Down Expand Up @@ -423,26 +422,6 @@ impl Socket {
}
}

impl Drop for Socket {
fn drop(&mut self) {
let sender = self.state_command_tx.clone();
let handle = self.join_handle.take();

tokio::spawn(async move {
let Some(handle) = handle else {
return;
};

if sender.send(StateCommand::Shutdown).await.is_ok() {
// the only errors still kill the connection
let _ = handle.await;
} else {
handle.abort()
}
});
}
}

/// The status of the [Socket].
#[derive(Copy, Clone, Debug, Eq, PartialEq, uniffi::Enum)]
pub enum SocketStatus {
Expand Down

0 comments on commit 3c43e80

Please sign in to comment.