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:
@@ -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"),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user