From 362bfd827f522b57062e4ebcb465bb51941632a4 Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Fri, 4 Jul 2025 14:16:33 +0200 Subject: [PATCH] cli: drop extraneous daemon thread it was only needed because we forked subdaemons and couldn't reuse the main aio root. we now fork+exec, so the main aio root is always valid. Change-Id: Ia19e20d52d65fe72721292be091f182a8a77a7cb --- lix/nix/daemon.cc | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lix/nix/daemon.cc b/lix/nix/daemon.cc index a4a223952..75818d719 100644 --- a/lix/nix/daemon.cc +++ b/lix/nix/daemon.cc @@ -286,8 +286,7 @@ static std::pair authPeer(const PeerInfo & peer) * the client. Otherwise, decide based on the authentication settings * and user credentials (from the unix domain socket). */ -static void daemonLoop(AsyncIoRoot & aio, std::optional forceTrustClientOpt); -static void daemonLoopImpl(std::optional forceTrustClientOpt) +static void daemonLoop(AsyncIoRoot & aio, std::optional forceTrustClientOpt) { if (chdir("/") == -1) throw SysError("cannot change current directory"); @@ -386,20 +385,6 @@ static void daemonLoopImpl(std::optional forceTrustClientOpt) } } } -static void daemonLoop(AsyncIoRoot & aio, std::optional forceTrustClientOpt) -{ - // we can't reuse the external async io root since it'd be shared with the - // children we will create, potentially trashing state, but the *previous* - // root is still alive as far as kj is concerned. we cannot recreate it in - // the child easily because darwin closes kqueues after fork, and since kj - // asserts after the kqueue close returns EBADF we'll die. the least awful - // way around this is to run the daemon loop in its own thread, without an - // async io root, and thus not have any shared state after we have forked. - std::async(std::launch::async, [&] { - ReceiveInterrupts ri; - return daemonLoopImpl(forceTrustClientOpt); - }).get(); -} static void daemonInstance(AsyncIoRoot & aio, std::optional forceTrustClientOpt) {