Archived
1
0
Fork 0

store: Remove unused variable and 'socket' call.

* guix/store.scm (open-inet-socket): Remove unused 'sock' variable.
This commit is contained in:
Ludovic Courtès 2022-09-03 18:44:32 +02:00
parent eedf71f948
commit 2028419e30
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -471,41 +471,38 @@
(define (open-inet-socket host port) (define (open-inet-socket host port)
"Connect to the Unix-domain socket at HOST:PORT and return it. Raise a "Connect to the Unix-domain socket at HOST:PORT and return it. Raise a
'&store-connection-error' upon error." '&store-connection-error' upon error."
(let ((sock (with-fluids ((%default-port-encoding #f)) (define addresses
;; This trick allows use of the `scm_c_read' optimization. (getaddrinfo host
(socket PF_UNIX SOCK_STREAM 0)))) (if (number? port) (number->string port) port)
(define addresses (if (number? port)
(getaddrinfo host (logior AI_ADDRCONFIG AI_NUMERICSERV)
(if (number? port) (number->string port) port) AI_ADDRCONFIG)
(if (number? port) 0 ;any address family
(logior AI_ADDRCONFIG AI_NUMERICSERV) SOCK_STREAM)) ;TCP only
AI_ADDRCONFIG)
0 ;any address family
SOCK_STREAM)) ;TCP only
(let loop ((addresses addresses)) (let loop ((addresses addresses))
(match addresses (match addresses
((ai rest ...) ((ai rest ...)
(let ((s (socket (addrinfo:fam ai) (let ((s (socket (addrinfo:fam ai)
;; TCP/IP only ;; TCP/IP only
SOCK_STREAM IPPROTO_IP))) SOCK_STREAM IPPROTO_IP)))
(catch 'system-error (catch 'system-error
(lambda () (lambda ()
(connect s (addrinfo:addr ai)) (connect s (addrinfo:addr ai))
;; Setting this option makes a dramatic difference because it ;; Setting this option makes a dramatic difference because it
;; avoids the "ACK delay" on our RPC messages. ;; avoids the "ACK delay" on our RPC messages.
(setsockopt s IPPROTO_TCP TCP_NODELAY 1) (setsockopt s IPPROTO_TCP TCP_NODELAY 1)
s) s)
(lambda args (lambda args
;; Connection failed, so try one of the other addresses. ;; Connection failed, so try one of the other addresses.
(close s) (close s)
(if (null? rest) (if (null? rest)
(raise (condition (&store-connection-error (raise (condition (&store-connection-error
(file host) (file host)
(errno (system-error-errno args))))) (errno (system-error-errno args)))))
(loop rest)))))))))) (loop rest)))))))))
(define (connect-to-daemon uri) (define (connect-to-daemon uri)
"Connect to the daemon at URI, a string that may be an actual URI or a file "Connect to the daemon at URI, a string that may be an actual URI or a file