Skip to content

Commit

Permalink
Merge pull request #8168 from angerman/angerman/mac-fix-recursive-nix
Browse files Browse the repository at this point in the history
macOS: fix recursive nix
  • Loading branch information
Ericson2314 authored Jun 9, 2023
2 parents 3c78920 + 381a329 commit 03f9ff6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 19 additions & 4 deletions src/libstore/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ void LocalDerivationGoal::startDaemon()
(struct sockaddr *) &remoteAddr, &remoteAddrLen);
if (!remote) {
if (errno == EINTR || errno == EAGAIN) continue;
if (errno == EINVAL) break;
if (errno == EINVAL || errno == ECONNABORTED) break;
throw SysError("accepting connection");
}

Expand Down Expand Up @@ -1487,8 +1487,22 @@ void LocalDerivationGoal::startDaemon()

void LocalDerivationGoal::stopDaemon()
{
if (daemonSocket && shutdown(daemonSocket.get(), SHUT_RDWR) == -1)
throw SysError("shutting down daemon socket");
if (daemonSocket && shutdown(daemonSocket.get(), SHUT_RDWR) == -1) {
// According to the POSIX standard, the 'shutdown' function should
// return an ENOTCONN error when attempting to shut down a socket that
// hasn't been connected yet. This situation occurs when the 'accept'
// function is called on a socket without any accepted connections,
// leaving the socket unconnected. While Linux doesn't seem to produce
// an error for sockets that have only been accepted, more
// POSIX-compliant operating systems like OpenBSD, macOS, and others do
// return the ENOTCONN error. Therefore, we handle this error here to
// avoid raising an exception for compliant behaviour.
if (errno == ENOTCONN) {
daemonSocket.close();
} else {
throw SysError("shutting down daemon socket");
}
}

if (daemonThread.joinable())
daemonThread.join();
Expand All @@ -1499,7 +1513,8 @@ void LocalDerivationGoal::stopDaemon()
thread.join();
daemonWorkerThreads.clear();

daemonSocket = -1;
// release the socket.
daemonSocket.close();
}


Expand Down
3 changes: 0 additions & 3 deletions tests/recursive.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
source common.sh

# FIXME
if [[ $(uname) != Linux ]]; then skipTest "Not running Linux"; fi

enableFeatures 'recursive-nix'
restartDaemon

Expand Down

0 comments on commit 03f9ff6

Please sign in to comment.