GNU bug report logs

#70947 [PATCH] store: Refactor connect-to-daemon.

PackageSource(s)Maintainer(s)
guix-patches PTS Buildd Popcon
Reply or subscribe to this bug. View this bug as an mbox, status mbox, or maintainer mbox

Report forwarded to guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org:
bug#70947; Package guix-patches. (Tue, 14 May 2024 16:57:02 GMT) (full text, mbox, link).


Acknowledgement sent to Christopher Baines <mail@cbaines.net>:
New bug report received and forwarded. Copy sent to guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org. (Tue, 14 May 2024 16:57:02 GMT) (full text, mbox, link).


Message #5 received at submit@debbugs.gnu.org (full text, mbox, reply):

From: Christopher Baines <mail@cbaines.net>
To: guix-patches@gnu.org
Subject: [PATCH] store: Refactor connect-to-daemon.
Date: Tue, 14 May 2024 17:56:05 +0100
Remove the inner connect procedure, as now that #:non-blocking? needs passing
on, this just makes things more difficult.  This commit also fixes not passing
 #:non-blocking? on in the case where open-unix-domain-socket is called as
connect.

* guix/store.scm (connect-to-daemon): Refactor and fix non-blocking
connections to sockets with a filename.

Change-Id: I61cd99920df91baba95567d670bec6fa94043875
---
 guix/store.scm | 69 +++++++++++++++++++++++---------------------------
 1 file changed, 32 insertions(+), 37 deletions(-)

diff --git a/guix/store.scm b/guix/store.scm
index 58ddaa8d15..4070b686cb 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -524,50 +524,45 @@ (define* (open-inet-socket host port #:key non-blocking?)
                                     (errno (system-error-errno args)))))
                  (loop rest)))))))))
 
-(define* (connect-to-daemon uri #:key non-blocking?)
-  "Connect to the daemon at URI, a string that may be an actual URI or a file
-name, and return an input/output port.  If NON-BLOCKING?, use a non-blocking
-socket when using the file, unix or guix URI schemes.
+(define* (connect-to-daemon uri-or-filename #:key non-blocking?)
+  "Connect to the daemon at URI-OR-FILENAME and return an input/output port.
+If NON-BLOCKING?, use a non-blocking socket when using the file, unix or guix
+URI schemes.
 
 This is a low-level procedure that does not perform the initial handshake with
 the daemon.  Use 'open-connection' for that."
   (define (not-supported)
     (raise (condition (&store-connection-error
-                       (file uri)
+                       (file uri-or-filename)
                        (errno ENOTSUP)))))
 
-  (define connect
-    (match (string->uri uri)
-      (#f                                         ;URI is a file name
-       open-unix-domain-socket)
-      ((? uri? uri)
-       (match (uri-scheme uri)
-         ((or #f 'file 'unix)
-          (lambda (_)
-            (open-unix-domain-socket (uri-path uri)
-                                     #:non-blocking? non-blocking?)))
-         ('guix
-          (lambda (_)
-            (open-inet-socket (uri-host uri)
-                              (or (uri-port uri) %default-guix-port)
-                              #:non-blocking? non-blocking?)))
-         ((? symbol? scheme)
-          ;; Try to dynamically load a module for SCHEME.
-          ;; XXX: Errors are swallowed.
-          (match (false-if-exception
-                  (resolve-interface `(guix store ,scheme)))
-            ((? module? module)
-             (match (false-if-exception
-                     (module-ref module 'connect-to-daemon))
-               ((? procedure? connect)
-                (lambda (_)
-                  (connect uri)))
-               (x (not-supported))))
-            (#f (not-supported))))
-         (x
-          (not-supported))))))
-
-  (connect uri))
+  (match (string->uri uri-or-filename)
+    (#f                                 ;URI is a file name
+     (open-unix-domain-socket uri-or-filename
+                              #:non-blocking? non-blocking?))
+    ((? uri? uri)
+     (match (uri-scheme uri)
+       ((or #f 'file 'unix)
+        (open-unix-domain-socket (uri-path uri)
+                                 #:non-blocking? non-blocking?))
+       ('guix
+        (open-inet-socket (uri-host uri)
+                          (or (uri-port uri) %default-guix-port)
+                          #:non-blocking? non-blocking?))
+       ((? symbol? scheme)
+        ;; Try to dynamically load a module for SCHEME.
+        ;; XXX: Errors are swallowed.
+        (match (false-if-exception
+                (resolve-interface `(guix store ,scheme)))
+          ((? module? module)
+           (match (false-if-exception
+                   (module-ref module 'connect-to-daemon))
+             ((? procedure? connect)
+              (connect uri))
+             (x (not-supported))))
+          (#f (not-supported))))
+       (x
+        (not-supported))))))
 
 (define* (open-connection #:optional (uri (%daemon-socket-uri))
                           #:key port (reserve-space? #t) cpu-affinity

base-commit: 6e86089d563ccb67ae04cd941ca7b66c1777831f
-- 
2.41.0





Reply sent to Christopher Baines <mail@cbaines.net>:
You have taken responsibility. (Sat, 29 Jun 2024 11:41:02 GMT) (full text, mbox, link).


Notification sent to Christopher Baines <mail@cbaines.net>:
bug acknowledged by developer. (Sat, 29 Jun 2024 11:41:02 GMT) (full text, mbox, link).


Message #10 received at 70947-done@debbugs.gnu.org (full text, mbox, reply):

From: Christopher Baines <mail@cbaines.net>
To: 70947-done@debbugs.gnu.org
Subject: Re: [bug#70947] [PATCH] store: Refactor connect-to-daemon.
Date: Sat, 29 Jun 2024 12:39:35 +0100
[Message part 1 (text/plain, inline)]
Christopher Baines <mail@cbaines.net> writes:

> Remove the inner connect procedure, as now that #:non-blocking? needs passing
> on, this just makes things more difficult.  This commit also fixes not passing
>  #:non-blocking? on in the case where open-unix-domain-socket is called as
> connect.
>
> * guix/store.scm (connect-to-daemon): Refactor and fix non-blocking
> connections to sockets with a filename.
>
> Change-Id: I61cd99920df91baba95567d670bec6fa94043875
> ---
>  guix/store.scm | 69 +++++++++++++++++++++++---------------------------
>  1 file changed, 32 insertions(+), 37 deletions(-)

I pushed this to master as ffdbf1f11ee68e127216cb6682e93b490c7e1d0d.
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs@gnu.org> to internal_control@debbugs.gnu.org. (Sun, 28 Jul 2024 11:24:11 GMT) (full text, mbox, link).


Send a report that this bug log contains spam.


debbugs.gnu.org maintainers <help-debbugs@gnu.org>. Last modified: Sun Sep 8 03:07:31 2024; Machine Name: wallace-server

GNU bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.