Skip to content

Commit

Permalink
Don't return client,processor,notification if there was a panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmedrano committed Sep 13, 2024
1 parent 2b4e565 commit 39a3af9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/client/async_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<N, P> AsyncClient<N, P> {
if self.callback.is_none() {
return Err(Error::ClientIsNoLongerAlive);
}
let cb = self.callback.take().unwrap();
let cb = self.callback.take().ok_or(Error::ClientIsNoLongerAlive)?;
let client = cb.client.raw();

// deactivate
Expand All @@ -124,7 +124,13 @@ impl<N, P> AsyncClient<N, P> {
sleep_on_test();
clear_callbacks(client)?;
// done, take ownership of callback
Ok(cb)
if cb.is_valid.load(std::sync::atomic::Ordering::Relaxed) {
Ok(cb)
} else {
std::mem::forget(cb.notification);
std::mem::forget(cb.process);
Err(Error::ClientIsNoLongerAlive)
}
}
}

Expand Down

0 comments on commit 39a3af9

Please sign in to comment.