summary refs log tree commit diff
path: root/tests/zlib.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-10-11 15:14:16 +0200
committerLudovic Courtès <ludo@gnu.org>2017-10-11 15:20:50 +0200
commit85a2b58987bc32e33e63bea86c1a94496b796ae9 (patch)
treed79a3dc6c8ac09ee27cf15aa487258da1069c2b5 /tests/zlib.scm
parent5781c7dd27b8d96cef2e54693ca3ac91f69b4bda (diff)
downloadguix-85a2b58987bc32e33e63bea86c1a94496b796ae9.tar.gz
zlib: Fix memory leak due to revealed ports not being GC'd.
Fixes <https://bugs.gnu.org/28784>.

This mostly reverts 81a0f1cdf12e7bcc34c1203f034a323fa8f52cf5, which
introduced a regression: revealed ports are *never* GC'd (contrary to
what Guile's manual suggests).

In addition to the revert, 'close-procedure' now explicitly swallows
EBADF errors when 'close-port' is called.

* guix/zlib.scm (close-procedure): New procedure.
(make-gzip-input-port)[gzfile]: Use 'fileno' instead of 'port->fdes'.
Use 'close-procedure' instead of 'gzclose'.
(make-gzip-output-port): Likewise.
* tests/zlib.scm ("compression/decompression pipe"): Use 'port-closed?'
to determine whether PARENT has been closed.
Diffstat (limited to 'tests/zlib.scm')
-rw-r--r--tests/zlib.scm11
1 files changed, 1 insertions, 10 deletions
diff --git a/tests/zlib.scm b/tests/zlib.scm
index f71609b7c5..5455240a71 100644
--- a/tests/zlib.scm
+++ b/tests/zlib.scm
@@ -57,16 +57,7 @@
               (match (waitpid pid)
                 ((_ . status)
                  (and (zero? status)
-
-                      ;; PORT itself isn't closed but its underlying file
-                      ;; descriptor must have been closed by 'gzclose'.
-                      (catch 'system-error
-                        (lambda ()
-                          (seek (fileno parent) 0 SEEK_CUR)
-                          #f)
-                        (lambda args
-                          (= EBADF (system-error-errno args))))
-
+                      (port-closed? parent)
                       (bytevector=? received data))))))))))))
 
 (test-end)