summaryrefslogtreecommitdiff
path: root/guix/store.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2017-05-05 15:32:16 +0200
committerLudovic Courtès <ludo@gnu.org>2017-05-07 00:18:36 +0200
commit950d51c9d9a5107c5dac279da7d2e431134b5f43 (patch)
tree0fa786f9c52d0a36b9a47811792fc6cf51e9e3ed /guix/store.scm
parent74b86713788ab7cb8fcd9808dba22580c792ccee (diff)
downloadgnu-guix-950d51c9d9a5107c5dac279da7d2e431134b5f43.tar
gnu-guix-950d51c9d9a5107c5dac279da7d2e431134b5f43.tar.gz
store: Use 'TCP_NODELAY' when connecting to a daemon over PF_INET.
* guix/store.scm (open-inet-socket): Add 'cond-expand' form to define 'TCP_NODELAY' when needed. Add call to 'setsockopt' after 'connect'.
Diffstat (limited to 'guix/store.scm')
-rw-r--r--guix/store.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/guix/store.scm b/guix/store.scm
index b71c47b9bb..c94dfea959 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -382,6 +382,11 @@
(define (open-inet-socket host port)
"Connect to the Unix-domain socket at HOST:PORT and return it. Raise a
'&nix-connection-error' upon error."
+ ;; Define 'TCP_NODELAY' on Guile 2.0. The value is the same on all GNU
+ ;; systems.
+ (cond-expand (guile-2.2 #t)
+ (else (define TCP_NODELAY 1)))
+
(let ((sock (with-fluids ((%default-port-encoding #f))
;; This trick allows use of the `scm_c_read' optimization.
(socket PF_UNIX SOCK_STREAM 0))))
@@ -402,6 +407,10 @@
(catch 'system-error
(lambda ()
(connect s (addrinfo:addr ai))
+
+ ;; Setting this option makes a dramatic difference because it
+ ;; avoids the "ACK delay" on our RPC messages.
+ (setsockopt s IPPROTO_TCP TCP_NODELAY 1)
s)
(lambda args
;; Connection failed, so try one of the other addresses.