terminate worker thread as soon as possible to avoid race conditions

This commit is contained in:
Henrik Friedrichsen
2020-06-14 19:57:33 +02:00
parent 4d3c071328
commit d7c170fec8

View File

@@ -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;
}