terminate worker thread as soon as possible to avoid race conditions
This commit is contained in:
@@ -143,6 +143,12 @@ impl futures::Future for Worker {
|
||||
loop {
|
||||
let mut progress = false;
|
||||
|
||||
if self.session.is_invalid() {
|
||||
self.player.stop();
|
||||
self.events.send(Event::Player(PlayerEvent::Stopped));
|
||||
return Poll::Ready(Result::Err(()));
|
||||
}
|
||||
|
||||
if let Poll::Ready(Some(cmd)) = self.commands.as_mut().poll_next(cx) {
|
||||
progress = true;
|
||||
debug!("message received!");
|
||||
@@ -216,11 +222,6 @@ impl futures::Future for Worker {
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if self.session.is_invalid() {
|
||||
self.events.send(Event::Player(PlayerEvent::Stopped));
|
||||
return Poll::Ready(Result::Err(()));
|
||||
}
|
||||
|
||||
if !progress {
|
||||
return Poll::Pending;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user