forked from lix-project/lix
Use nix::connect() to connect to the garbage collector
This commit is contained in:
parent
22c35ea5b8
commit
33d04e8a8d
1 changed files with 2 additions and 12 deletions
|
@ -123,20 +123,10 @@ void LocalStore::addTempRoot(const StorePath & path)
|
||||||
collector is running. So we have to connect to the garbage
|
collector is running. So we have to connect to the garbage
|
||||||
collector and inform it about our root. */
|
collector and inform it about our root. */
|
||||||
if (!state->fdRootsSocket) {
|
if (!state->fdRootsSocket) {
|
||||||
state->fdRootsSocket = createUnixDomainSocket();
|
|
||||||
|
|
||||||
auto socketPath = stateDir.get() + gcSocketPath;
|
auto socketPath = stateDir.get() + gcSocketPath;
|
||||||
|
|
||||||
debug("connecting to '%s'", socketPath);
|
debug("connecting to '%s'", socketPath);
|
||||||
|
state->fdRootsSocket = createUnixDomainSocket();
|
||||||
struct sockaddr_un addr;
|
nix::connect(state->fdRootsSocket.get(), socketPath);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue