From 33d04e8a8d9ab8f1736b7fe725e8851fbc41e1e7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 28 Oct 2021 22:14:47 +0200 Subject: [PATCH] Use nix::connect() to connect to the garbage collector --- src/libstore/gc.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/libstore/gc.cc b/src/libstore/gc.cc index 13412e504..8030c84f5 100644 --- a/src/libstore/gc.cc +++ b/src/libstore/gc.cc @@ -123,20 +123,10 @@ void LocalStore::addTempRoot(const StorePath & path) collector is running. So we have to connect to the garbage collector and inform it about our root. */ if (!state->fdRootsSocket) { - state->fdRootsSocket = createUnixDomainSocket(); - auto socketPath = stateDir.get() + gcSocketPath; - debug("connecting to '%s'", socketPath); - - struct sockaddr_un addr; - addr.sun_family = AF_UNIX; - if (socketPath.size() + 1 >= sizeof(addr.sun_path)) - throw Error("socket path '%s' is too long", socketPath); - strcpy(addr.sun_path, socketPath.c_str()); - - if (::connect(state->fdRootsSocket.get(), (struct sockaddr *) &addr, sizeof(addr)) == -1) - throw SysError("cannot connect to garbage collector at '%s'", socketPath); + state->fdRootsSocket = createUnixDomainSocket(); + nix::connect(state->fdRootsSocket.get(), socketPath); } try {