timeout handles (#966)

* timeout handles

* more
This commit is contained in:
Logan McNaughton
2026-05-28 11:12:40 +02:00
committed by GitHub
parent 9dfc42c723
commit 3197d415e0
2 changed files with 13 additions and 4 deletions
+7 -2
View File
@@ -181,11 +181,16 @@ pub async fn unload_game(
discord_watch_tx: Option<tokio::sync::watch::Sender<()>>,
discord_handle: Option<tokio::task::JoinHandle<()>>,
) {
if let Some(discord_handle) = discord_handle
if let Some(mut discord_handle) = discord_handle
&& let Some(discord_watch_tx) = discord_watch_tx
{
let _ = discord_watch_tx.send(());
discord_handle.await.unwrap();
if tokio::time::timeout(std::time::Duration::from_secs(1), &mut discord_handle)
.await
.is_err()
{
discord_handle.abort();
}
}
unsafe { ra_unload_game() };
}
+6 -2
View File
@@ -179,8 +179,12 @@ pub async fn close(
usb_handle: Option<tokio::task::JoinHandle<()>>,
) {
let _ = shutdown_tx.send(());
if let Some(handle) = usb_handle {
handle.await.unwrap();
if let Some(mut handle) = usb_handle
&& tokio::time::timeout(std::time::Duration::from_secs(1), &mut handle)
.await
.is_err()
{
handle.abort();
}
}