From b29ce1a22298449f7e838821ec7afbef6157ae81 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Tue, 14 Feb 2023 21:03:45 +0100 Subject: [PATCH] node: Fix bug when socket file is deleted If the socket file is deleted while the node is running, we can no longer quit with Ctrl-C. This is the "fix". --- radicle-node/src/runtime.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/radicle-node/src/runtime.rs b/radicle-node/src/runtime.rs index dda63a53..8ea179ab 100644 --- a/radicle-node/src/runtime.rs +++ b/radicle-node/src/runtime.rs @@ -230,13 +230,15 @@ impl Runtime { self.pool.run().unwrap(); self.reactor.join().unwrap(); - control.join().unwrap()?; daemon::kill(&daemon).ok(); // Ignore error if daemon has already exited, for whatever reason. daemon.wait()?; - fs::remove_file(home.socket()).ok(); - + // If the socket file was deleted by some other process, for whatever reason, + // the control thread will not be able to join. + if fs::remove_file(home.socket()).is_ok() { + control.join().unwrap()?; + } log::debug!(target: "node", "Node shutdown completed for {}", self.id); Ok(())