1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 09:49:36 +01:00

RemoteStore: Make thread-safe

This allows a RemoteStore object to be used safely from multiple
threads concurrently. It will make multiple daemon connections if
necessary.

Note: pool.hh and sync.hh have been copied from the Hydra source tree.
This commit is contained in:
Eelco Dolstra 2016-02-23 15:00:59 +01:00
parent c0b7a8a0b5
commit e292144d46
4 changed files with 414 additions and 235 deletions

View file

@ -12,6 +12,7 @@ class Pipe;
class Pid;
struct FdSink;
struct FdSource;
template<typename T> class Pool;
class RemoteStore : public Store
@ -91,19 +92,22 @@ public:
bool verifyStore(bool checkContents, bool repair) override;
private:
AutoCloseFD fdSocket;
FdSink to;
FdSource from;
unsigned int daemonVersion;
bool initialised;
void openConnection(bool reserveSpace = true);
struct Connection
{
AutoCloseFD fd;
FdSink to;
FdSource from;
unsigned int daemonVersion;
void processStderr(Sink * sink = 0, Source * source = 0);
void processStderr(Sink * sink = 0, Source * source = 0);
};
void connectToDaemon();
ref<Pool<Connection>> connections;
void setOptions();
ref<Connection> openConnection(bool reserveSpace = true);
void setOptions(ref<Connection> conn);
};