summaryrefslogtreecommitdiff
path: root/guix/http-client.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-05-23 22:19:37 +0200
committerLudovic Courtès <ludo@gnu.org>2014-05-23 22:19:37 +0200
commita68d976b666a5097585cf221f4f8d793f90f3464 (patch)
tree66585e61ec97ecbcf9107f17cad79a7075b400cf /guix/http-client.scm
parentfb729425dcd80b8ef34c075867d2f204bc4d55cb (diff)
downloadgnu-guix-a68d976b666a5097585cf221f4f8d793f90f3464.tar
gnu-guix-a68d976b666a5097585cf221f4f8d793f90f3464.tar.gz
download: Enlarge your receive buffer.
* guix/build/download.scm (open-connection-for-uri): Remove call to 'setsockopt'. * guix/http-client.scm (open-socket-for-uri)[rmem-max, buffer-size]: New variables. Add call to 'setsockopt'.
Diffstat (limited to 'guix/http-client.scm')
-rw-r--r--guix/http-client.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/guix/http-client.scm b/guix/http-client.scm
index 1f05df4b05..4770628e45 100644
--- a/guix/http-client.scm
+++ b/guix/http-client.scm
@@ -162,7 +162,19 @@ closed it will also close PORT, unless the KEEP-ALIVE? is true."
(define* (open-socket-for-uri uri #:key (buffered? #t))
"Return an open port for URI. When BUFFERED? is false, the returned port is
unbuffered."
+ (define rmem-max
+ ;; The maximum size for a receive buffer on Linux, see socket(7).
+ "/proc/sys/net/core/rmem_max")
+
+ (define buffer-size
+ (if (file-exists? rmem-max)
+ (call-with-input-file rmem-max read)
+ 126976)) ; the default for Linux, per 'rmem_default'
+
(let ((s ((@ (web client) open-socket-for-uri) uri)))
+ ;; Work around <http://bugs.gnu.org/15368> by restoring a decent
+ ;; buffer size.
+ (setsockopt s SOL_SOCKET SO_RCVBUF buffer-size)
(unless buffered?
(setvbuf s _IONBF))
s))