mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-21 01:32:32 +00:00
fix: retry PipeServer::bind on stale pipe handles
Some checks failed
Continuous integration / test (push) Has been cancelled
Some checks failed
Continuous integration / test (push) Has been cancelled
This commit is contained in:
parent
bbbe882faf
commit
42084bacf0
1 changed files with 12 additions and 1 deletions
|
|
@ -218,7 +218,16 @@ impl MainWindow {
|
||||||
}
|
}
|
||||||
}); // thread
|
}); // thread
|
||||||
|
|
||||||
if let Ok(mut listener) = PipeServer::bind(socket_path) {
|
// Retry: a stale FIRST_PIPE_INSTANCE handle returns ERROR_ACCESS_DENIED briefly.
|
||||||
|
let listener = (0..5).find_map(|attempt| match PipeServer::bind(socket_path) {
|
||||||
|
Ok(listener) => Some(listener),
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("PipeServer::bind failed (attempt {}): {err}", attempt + 1);
|
||||||
|
thread::sleep(time::Duration::from_millis(100 * (attempt + 1)));
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if let Some(mut listener) = listener {
|
||||||
let focus_sender = self.focus_notice.sender();
|
let focus_sender = self.focus_notice.sender();
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
if let Ok(mut stream) = listener.accept() {
|
if let Ok(mut stream) = listener.accept() {
|
||||||
|
|
@ -232,6 +241,8 @@ impl MainWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
eprintln!("PipeServer::bind failed after retries; single-instance forwarding disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read message from player
|
// Read message from player
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue