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
This commit is contained in:
+1
-16
@@ -286,8 +286,7 @@ static std::pair<TrustedFlag, std::string> 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<TrustedFlag> forceTrustClientOpt);
|
||||
static void daemonLoopImpl(std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
static void daemonLoop(AsyncIoRoot & aio, std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
{
|
||||
if (chdir("/") == -1)
|
||||
throw SysError("cannot change current directory");
|
||||
@@ -386,20 +385,6 @@ static void daemonLoopImpl(std::optional<TrustedFlag> forceTrustClientOpt)
|
||||
}
|
||||
}
|
||||
}
|
||||
static void daemonLoop(AsyncIoRoot & aio, std::optional<TrustedFlag> 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<TrustedFlag> forceTrustClientOpt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user