about summary refs log tree commit diff
path: root/src/libstore/remote-store.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-23T14·00+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-23T14·00+0100
commite292144d46e3fbb24ee9ee67f1682b268373921b (patch)
tree318c8baaca0739076dcbcbe0d530f5e8d97fc204 /src/libstore/remote-store.hh
parentc0b7a8a0b576d5fcbcb25c412836dc885b7eb0fe (diff)
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.
Diffstat (limited to 'src/libstore/remote-store.hh')
-rw-r--r--src/libstore/remote-store.hh22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index f15182285e8c..b16a6b51db0f 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -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);
 };