guix-commits
[Top][All Lists]
Advanced

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

04/05: import: cran: Fix file descriptor leak.


From: guix-commits
Subject: 04/05: import: cran: Fix file descriptor leak.
Date: Fri, 3 Jan 2020 10:09:30 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit af0aefd8c10701fa32341506e36297e5105f6143
Author: Ludovic Courtès <address@hidden>
Date:   Fri Jan 3 16:01:11 2020 +0100

    import: cran: Fix file descriptor leak.
    
    Fixes <https://bugs.gnu.org/38836>.
    Reported by Ricardo Wurmus <address@hidden>.
    
    * guix/import/cran.scm (bioconductor-packages-list): Close the port
    returned by 'http-fetch/cached'.
    (fetch-description): Likewise.
---
 guix/import/cran.scm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/guix/import/cran.scm b/guix/import/cran.scm
index f3f1747..13771ec 100644
--- a/guix/import/cran.scm
+++ b/guix/import/cran.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <address@hidden>
-;;; Copyright © 2015, 2016, 2017, 2019 Ludovic Courtès <address@hidden>
+;;; Copyright © 2015, 2016, 2017, 2019, 2020 Ludovic Courtès <address@hidden>
 ;;; Copyright © 2017 Mathieu Othacehe <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -161,7 +161,10 @@ release."
       ;; alist of attributes.
       (map (lambda (chunk)
              (description->alist (string-join chunk "\n")))
-           (chunk-lines (read-lines (http-fetch/cached url)))))))
+           (let* ((port  (http-fetch/cached url))
+                  (lines (read-lines port)))
+             (close-port port)
+             (chunk-lines lines))))))
 
 (define* (latest-bioconductor-package-version name #:optional type)
   "Return the version string corresponding to the latest release of the
@@ -206,7 +209,10 @@ from ~s: ~a (~s)~%"
                           (http-get-error-code c)
                           (http-get-error-reason c))
                   #f))
-         (description->alist (read-string (http-fetch url))))))
+         (let* ((port   (http-fetch url))
+                (result (description->alist (read-string port))))
+           (close-port port)
+           result))))
     ((bioconductor)
      ;; Currently, the bioconductor project does not offer a way to access a
      ;; package's DESCRIPTION file over HTTP, so we determine the version,



reply via email to

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