guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/05: store: Add 'port->connection'.


From: Ludovic Courtès
Subject: 01/05: store: Add 'port->connection'.
Date: Tue, 26 Jun 2018 08:29:58 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 2f608c14893a025b471bcd993096f92331a45a12
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jun 25 18:40:10 2018 +0200

    store: Add 'port->connection'.
    
    * guix/store.scm (port->connection): New procedure.
---
 guix/store.scm | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/guix/store.scm b/guix/store.scm
index 773d53e..3bf5657 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -65,6 +65,7 @@
             build-mode
 
             open-connection
+            port->connection
             close-connection
             with-store
             set-build-options
@@ -517,6 +518,23 @@ for this connection will be pinned.  Return a server 
object."
                           (or done? (process-stderr conn)))
                         conn)))))))))
 
+(define* (port->connection port
+                           #:key (version %protocol-version))
+  "Assimilate PORT, an input/output port, and return a connection to the
+daemon, assuming the given protocol VERSION.
+
+Warning: this procedure assumes that the initial handshake with the daemon has
+already taken place on PORT and that we're just continuing on this established
+connection.  Use with care."
+  (let-values (((output flush)
+                (buffering-output-port port (make-bytevector 8192))))
+    (%make-nix-server port
+                      (protocol-major version)
+                      (protocol-minor version)
+                      output flush
+                      (make-hash-table 100)
+                      (make-hash-table 100))))
+
 (define (write-buffered-output server)
   "Flush SERVER's output port."
   (force-output (nix-server-output-port server))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]