Make worker command delivery more resilient

This may discard commands during reauthentication, but at least it doesn't crash
the application.

May help with #993 and #1257
This commit is contained in:
Henrik Friedrichsen
2023-08-29 21:47:07 +02:00
parent b4a397c84d
commit c0c7ea8828

View File

@@ -337,9 +337,17 @@ impl Spotify {
}
fn send_worker(&self, cmd: WorkerCommand) {
info!("sending command to worker: {:?}", cmd);
let channel = self.channel.read().expect("can't readlock worker channel");
match channel.as_ref() {
Some(channel) => channel.send(cmd).expect("can't send message to worker"),
Some(channel) => {
if let Err(e) = channel.send(cmd) {
error!(
"can't send command to spotify worker: {}, dropping command",
e
);
}
}
None => error!("no channel to worker available"),
}
}