Don't create a Store in processConnection()

This commit is contained in:
Eelco Dolstra 2018-09-25 12:49:20 +02:00
parent 63b99af85a
commit 05819d013f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
3 changed files with 14 additions and 8 deletions

View file

@ -694,6 +694,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
} }
void processConnection( void processConnection(
ref<Store> store,
FdSource & from, FdSource & from,
FdSink & to, FdSink & to,
bool trusted, bool trusted,
@ -743,12 +744,6 @@ void processConnection(
throw Error("if you run 'nix-daemon' as root, then you MUST set 'build-users-group'!"); throw Error("if you run 'nix-daemon' as root, then you MUST set 'build-users-group'!");
#endif #endif
/* Open the store. */
Store::Params params; // FIXME: get params from somewhere
// Disable caching since the client already does that.
params["path-info-cache-size"] = "0";
auto store = openStore(settings.storeUri, params);
store->createUser(userName, userId); store->createUser(userName, userId);
tunnelLogger->stopWork(); tunnelLogger->stopWork();

View file

@ -1,8 +1,10 @@
#include "serialise.hh" #include "serialise.hh"
#include "store-api.hh"
namespace nix::daemon { namespace nix::daemon {
void processConnection( void processConnection(
ref<Store> store,
FdSource & from, FdSource & from,
FdSink & to, FdSink & to,
bool trusted, bool trusted,

View file

@ -140,6 +140,15 @@ static PeerInfo getPeerInfo(int remote)
#define SD_LISTEN_FDS_START 3 #define SD_LISTEN_FDS_START 3
static ref<Store> openUncachedStore()
{
Store::Params params; // FIXME: get params from somewhere
// Disable caching since the client already does that.
params["path-info-cache-size"] = "0";
return openStore(settings.storeUri, params);
}
static void daemonLoop(char * * argv) static void daemonLoop(char * * argv)
{ {
if (chdir("/") == -1) if (chdir("/") == -1)
@ -230,7 +239,7 @@ static void daemonLoop(char * * argv)
/* Handle the connection. */ /* Handle the connection. */
FdSource from(remote.get()); FdSource from(remote.get());
FdSink to(remote.get()); FdSink to(remote.get());
processConnection(from, to, trusted, user, peer.uid); processConnection(openUncachedStore(), from, to, trusted, user, peer.uid);
exit(0); exit(0);
}, options); }, options);
@ -312,7 +321,7 @@ static int _main(int argc, char * * argv)
} else { } else {
FdSource from(STDIN_FILENO); FdSource from(STDIN_FILENO);
FdSink to(STDOUT_FILENO); FdSink to(STDOUT_FILENO);
processConnection(from, to, true, "root", 0); processConnection(openUncachedStore(), from, to, true, "root", 0);
} }
} else { } else {
daemonLoop(argv); daemonLoop(argv);