forked from lix-project/lix
Recursive Nix: Handle concurrent client connections
This commit is contained in:
parent
c119ab9db0
commit
69326f3637
1 changed files with 21 additions and 10 deletions
|
@ -895,6 +895,9 @@ private:
|
||||||
/* The daemon main thread. */
|
/* The daemon main thread. */
|
||||||
std::thread daemonThread;
|
std::thread daemonThread;
|
||||||
|
|
||||||
|
/* The daemon worker threads. */
|
||||||
|
std::vector<std::thread> daemonWorkerThreads;
|
||||||
|
|
||||||
/* Paths that were added via recursive Nix calls. */
|
/* Paths that were added via recursive Nix calls. */
|
||||||
PathSet addedPaths;
|
PathSet addedPaths;
|
||||||
|
|
||||||
|
@ -2875,17 +2878,19 @@ void DerivationGoal::startDaemon()
|
||||||
|
|
||||||
debug("received daemon connection");
|
debug("received daemon connection");
|
||||||
|
|
||||||
// FIXME: process on a separate thread.
|
auto workerThread = std::thread([this, store, remote{std::move(remote)}]() {
|
||||||
FdSource from(remote.get());
|
FdSource from(remote.get());
|
||||||
FdSink to(remote.get());
|
FdSink to(remote.get());
|
||||||
try {
|
try {
|
||||||
daemon::processConnection(store, from, to,
|
daemon::processConnection(store, from, to,
|
||||||
daemon::NotTrusted, daemon::Recursive, "nobody", 65535);
|
daemon::NotTrusted, daemon::Recursive, "nobody", 65535);
|
||||||
|
debug("terminated daemon connection");
|
||||||
} catch (SysError &) {
|
} catch (SysError &) {
|
||||||
ignoreException();
|
ignoreException();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
debug("terminated daemon connection");
|
daemonWorkerThreads.push_back(std::move(workerThread));
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("daemon shutting down");
|
debug("daemon shutting down");
|
||||||
|
@ -2901,6 +2906,12 @@ void DerivationGoal::stopDaemon()
|
||||||
if (daemonThread.joinable())
|
if (daemonThread.joinable())
|
||||||
daemonThread.join();
|
daemonThread.join();
|
||||||
|
|
||||||
|
// FIXME: should prune worker threads more quickly.
|
||||||
|
// FIXME: shutdown the client socket to speed up worker termination.
|
||||||
|
for (auto & thread : daemonWorkerThreads)
|
||||||
|
thread.join();
|
||||||
|
daemonWorkerThreads.clear();
|
||||||
|
|
||||||
daemonSocket = -1;
|
daemonSocket = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue