aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/gc.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2021-12-13 16:14:57 +0100
committerEelco Dolstra <edolstra@gmail.com>2021-12-13 19:00:19 +0100
commit05fcc681ac07c4ea04b365e6b03a76f3e6c54c94 (patch)
treebdf0adb9f3d23cd224c901d27c032598d0be51b0 /src/libstore/gc.cc
parent6d30f9e6fea7d451033653f8f167aef58f7f5347 (diff)
Retry on ECONNREFUSED
https://hydra.nixos.org/build/161439235
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r--src/libstore/gc.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc
index ee123d84e..fa68cd8f3 100644
--- a/src/libstore/gc.cc
+++ b/src/libstore/gc.cc
@@ -126,7 +126,17 @@ void LocalStore::addTempRoot(const StorePath & path)
auto socketPath = stateDir.get() + gcSocketPath;
debug("connecting to '%s'", socketPath);
state->fdRootsSocket = createUnixDomainSocket();
- nix::connect(state->fdRootsSocket.get(), socketPath);
+ try {
+ nix::connect(state->fdRootsSocket.get(), socketPath);
+ } catch (SysError & e) {
+ /* The garbage collector may have exited, so we need to
+ restart. */
+ if (e.errNo == ECONNREFUSED) {
+ debug("GC socket connection refused");
+ state->fdRootsSocket.close();
+ goto restart;
+ }
+ }
}
try {