diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-10-28 22:14:47 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-10-28 22:51:11 +0200 |
commit | 33d04e8a8d9ab8f1736b7fe725e8851fbc41e1e7 (patch) | |
tree | 37d7ce06cc35804ea2cbfa8b150237e8582615d8 /src/libstore/gc.cc | |
parent | 22c35ea5b86d4aa450c3517506576ed377437574 (diff) |
Use nix::connect() to connect to the garbage collector
Diffstat (limited to 'src/libstore/gc.cc')
-rw-r--r-- | src/libstore/gc.cc | 14 |
1 files 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 { |