guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/08: download: Abstract the receive buffer size.


From: Ludovic Courtès
Subject: 06/08: download: Abstract the receive buffer size.
Date: Fri, 27 Feb 2015 14:09:08 +0000

civodul pushed a commit to branch core-updates
in repository guix.

commit e7620dc9951132439abec2a49904aaeeb8de5397
Author: Ludovic Courtès <address@hidden>
Date:   Fri Feb 27 14:57:54 2015 +0100

    download: Abstract the receive buffer size.
    
    * guix/build/download.scm (%http-receive-buffer-size): New variable.
      (progress-proc, tls-wrap, http-fetch): Use it.
---
 guix/build/download.scm |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/guix/build/download.scm b/guix/build/download.scm
index e8d61e0..c439f6b 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <address@hidden>
+;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <address@hidden>
 ;;; Copyright © 2015 Mark H Weaver <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -42,6 +42,10 @@
 ;;;
 ;;; Code:
 
+(define %http-receive-buffer-size
+  ;; Size of the HTTP receive buffer.
+  65536)
+
 (define* (progress-proc file size #:optional (log-port (current-output-port)))
   "Return a procedure to show the progress of FILE's download, which is
 SIZE byte long.  The returned procedure is suitable for use as an
@@ -92,7 +96,7 @@ abbreviation of URI showing the scheme, host, and basename of 
the file."
     (call-with-output-file file
       (lambda (out)
         (dump-port in out
-                   #:buffer-size 65536            ; don't flood the log
+                   #:buffer-size %http-receive-buffer-size
                    #:progress (progress-proc (uri-abbreviation uri) size))))
 
     (ftp-close conn))
@@ -182,7 +186,7 @@ which is not available during bootstrap."
           (connect s (addrinfo:addr ai))
 
           ;; Buffer input and output on this port.
-          (setvbuf s _IOFBF)
+          (setvbuf s _IOFBF %http-receive-buffer-size)
 
           (if (eq? 'https (uri-scheme uri))
               (tls-wrap s (uri-host uri))
@@ -334,7 +338,7 @@ Return the resulting target URI."
              (if (port? bv-or-port)
                  (begin
                    (dump-port bv-or-port p
-                              #:buffer-size 65536 ; don't flood the log
+                              #:buffer-size %http-receive-buffer-size
                               #:progress (progress-proc (uri-abbreviation uri)
                                                         size))
                    (newline))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]