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

  • Done
  • quality assurance status badge
Details
One participant
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal
C
C
Christopher Baines wrote on 14 May 18:56 +0200
(address . guix-patches@gnu.org)
d42aea321f7c67d97611c80874c51055ee409021.1715705765.git.mail@cbaines.net
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(-)

Toggle diff (91 lines)
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
C
C
Christopher Baines wrote on 29 Jun 13:39 +0200
(address . 70947-done@debbugs.gnu.org)
87bk3k2d1k.fsf@cbaines.net
Christopher Baines <mail@cbaines.net> writes:

Toggle quote (13 lines)
> 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.
-----BEGIN PGP SIGNATURE-----

iQKlBAEBCgCPFiEEPonu50WOcg2XVOCyXiijOwuE9XcFAmZ/8ndfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcRHG1haWxAY2Jh
aW5lcy5uZXQACgkQXiijOwuE9XfPlw//QKSBSpUWo44DE4O4f2Wxw+f6zn5fywxj
fO/kE21bDXo5acTVbelzRI0VoH0aYd+m6TAfMNnhfg4W27tt1ZDt/TOxsuUWwUeC
zc71KyUQorsvDqMrOyfY/cJp1/2x+XpJhi1QbAw6qAIGBi9CKXk6RyZu/Z91zLrI
JOTu4TNSvPhWw8w+Rlgvijq0B0R+Uu6mZ3miHwamoKabg+XRsxGdhGdRppcybaTn
oXNwauQRvm1F9+Rdt/MhlhOVBGm3au2Mn+GbIKGbFsXvWWabPUjvMmaJAY+9Mz1T
xrQQXJZYkA8rQznUCp8pqiF2kwtX0DzwIFBZJwaXycHE6pQtoLyo98ATPE9ATq+6
ud6nVn5tHkO299Uqqd/JQ0cpWruKrRUae5OPtObmufmS9E8ixIAusz+zWkXDNkMc
v9eZwHBIU86J9/xbrc0H6OfS8clJjwKTkBlTPAlzKCf9LeJD2UrUQvCNmB4kPZqM
ub4y9Wmb+eNOhyGri/mm9GQzRGn9tVmU5Tg9gONKTTwWcit2EEBU8LL6p0bFus7/
jX0VIkAIF9jsM6x7IMMn+hta3epbWxCEcXiPq09VVpeJp8z0zrKxqf0KtVCqGB75
RBeWG/Q5ismTFALksEs3i3gOok8b3VM5HuPm6hi8gmnwIJfuxq+bTCpk1RxZSA62
d+QnA6qzK0w=
=BAWP
-----END PGP SIGNATURE-----

Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 70947@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 70947
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch