mirror of
https://github.com/Dasemu/Grove.git
synced 2026-11-26 23:36:11 +00:00
fix(gui): treat a reset connection to the instance socket as stale
Under load, connecting to a socket file whose listener is gone can fail with ECONNRESET instead of ECONNREFUSED; both mean no live instance. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
04750532f2
commit
430e25c31d
1 file changed
+6
-3
@@ -64,14 +64,17 @@ pub fn acquire_with(path: &Path, show: bool, timeout: Duration) -> std::io::Resu
|
|||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
match notify(path, if show { "show" } else { "ping" }, timeout) {
|
match notify(path, if show { "show" } else { "ping" }, timeout) {
|
||||||
Ok(()) => return Ok(Role::Secondary),
|
Ok(()) => return Ok(Role::Secondary),
|
||||||
// Nobody listens: a stale socket file from a crash is replaced.
|
// Nobody listens: a stale socket file from a crash is replaced. A reset
|
||||||
|
// (seen under load on a socket whose listener is gone) means the same.
|
||||||
Err(e)
|
Err(e)
|
||||||
if matches!(
|
if matches!(
|
||||||
e.kind(),
|
e.kind(),
|
||||||
std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::NotFound
|
std::io::ErrorKind::ConnectionRefused
|
||||||
|
| std::io::ErrorKind::ConnectionReset
|
||||||
|
| std::io::ErrorKind::NotFound
|
||||||
) =>
|
) =>
|
||||||
{
|
{
|
||||||
if e.kind() == std::io::ErrorKind::ConnectionRefused {
|
if e.kind() != std::io::ErrorKind::NotFound {
|
||||||
let _ = std::fs::remove_file(path);
|
let _ = std::fs::remove_file(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user