guix-commits
[Top][All Lists]
Advanced

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

branch version-1.2.0 updated: publish: Harmonize buffer size values and


From: guix-commits
Subject: branch version-1.2.0 updated: publish: Harmonize buffer size values and configuration.
Date: Mon, 16 Nov 2020 00:11:01 -0500

This is an automated email from the git hooks/post-receive script.

apteryx pushed a commit to branch version-1.2.0
in repository guix.

The following commit(s) were added to refs/heads/version-1.2.0 by this push:
     new 6306028  publish: Harmonize buffer size values and configuration.
6306028 is described below

commit 630602831dd93e7bc9a8e64fba958300e8cb0474
Author: Maxim Cournoyer <maxim.cournoyer@gmail.com>
AuthorDate: Tue Nov 10 16:59:13 2020 -0500

    publish: Harmonize buffer size values and configuration.
    
    This change harmonizes the way we configure the buffer sizes and the socket
    options, so that we don't forget to change it at one place like it happened 
in
    commit 5e3d169945935b53325e6b738a307ba286751259.
    
    * guix/scripts/publish.scm (%default-buffer-size)
    (%default-socket-options): New variables.
    * guix/scripts/publish.scm (configure-socket): New procedure.
    (compress-nar): Use %default-buffer-size for the buffer size, increased from
    128 to 208 KiB.
    (nar-response-port): Likewise, increased from 64 to 208 KiB.
    (http-write): Use configure-socket to set socket options.
    (open-server-socket): Likewise.
---
 guix/scripts/publish.scm | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index a976a9a..f1a9970 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org>
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès 
<ludo@gnu.org>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -250,6 +251,21 @@ usage."
     ("WantMassQuery" . 0)
     ("Priority" . 100)))
 
+;;; A common buffer size value used for the TCP socket SO_SNDBUF option and
+;;; the gzip compressor buffer size.
+(define %default-buffer-size
+  (* 208 1024))
+
+(define %default-socket-options
+  ;; List of options passed to 'setsockopt' when transmitting files.
+  (list (list SO_SNDBUF %default-buffer-size)))
+
+(define* (configure-socket socket #:key (level SOL_SOCKET)
+                           (options %default-socket-options))
+  "Apply multiple option tuples in OPTIONS to SOCKET, using LEVEL."
+  (for-each (cut apply setsockopt socket level <>)
+            options))
+
 (define (signed-string s)
   "Sign the hash of the string S with the daemon's key.  Return a canonical
 sexp for the signature."
@@ -569,7 +585,7 @@ requested using POOL."
        (lambda (port)
          (write-file item port))
        #:level (compression-level compression)
-       #:buffer-size (* 128 1024))
+       #:buffer-size %default-buffer-size)
      (rename-file (string-append nar ".tmp") nar))
     ('lzip
      ;; Note: the file port gets closed along with the lzip port.
@@ -866,7 +882,7 @@ or if EOF is reached."
      ;; 'make-gzip-output-port' wants a file port.
      (make-gzip-output-port (response-port response)
                             #:level level
-                            #:buffer-size (* 64 1024)))
+                            #:buffer-size %default-buffer-size))
     (($ <compression> 'lzip level)
      (make-lzip-output-port (response-port response)
                             #:level level))
@@ -891,8 +907,7 @@ blocking."
                                             client))
                (port        (begin
                               (force-output client)
-                              (setsockopt client SOL_SOCKET
-                                          SO_SNDBUF (* 128 1024))
+                              (configure-socket client)
                               (nar-response-port response compression))))
           ;; XXX: Given our ugly workaround for <http://bugs.gnu.org/21093> in
           ;; 'render-nar', BODY here is just the file name of the store item.
@@ -922,7 +937,7 @@ blocking."
                                                                          size)
                                                     client))
                           (output   (response-port response)))
-                     (setsockopt client SOL_SOCKET SO_SNDBUF (* 128 1024))
+                     (configure-socket client)
                      (if (file-port? output)
                          (sendfile output input size)
                          (dump-port input output))
@@ -1067,7 +1082,8 @@ methods, return the applicable compression."
 (define (open-server-socket address)
   "Return a TCP socket bound to ADDRESS, a socket address."
   (let ((sock (socket (sockaddr:fam address) SOCK_STREAM 0)))
-    (setsockopt sock SOL_SOCKET SO_REUSEADDR 1)
+    (configure-socket sock #:options (cons (list SO_REUSEADDR 1)
+                                           %default-socket-options))
     (bind sock address)
     sock))
 



reply via email to

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