Commit Graph

6 Commits

Author SHA1 Message Date
Ludovic Courtès 85f4f7b790
zlib: Fix race condition when closing gzip ports.
Fixes <https://bugs.gnu.org/29335>.

* guix/zlib.scm (close-procedure): Remove.
(make-gzip-input-port): Do (dup (fileno port)) to get a file descriptor
for 'gzdopen'.  Close PORT before returning.  Use 'gzclose' as the
'close' procedure of the returned port.
(make-gzip-output-port): Likewise.
2017-11-19 23:09:01 +01:00
Ludovic Courtès 85a2b58987
zlib: Fix memory leak due to revealed ports not being GC'd.
Fixes <https://bugs.gnu.org/28784>.

This mostly reverts 81a0f1cdf1, 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.
2017-10-11 15:20:50 +02:00
Ludovic Courtès 81a0f1cdf1
zlib: Don't rely on EBADF being ignored by 'fport_close'.
In 2.2, 'fport_close' no longer swallows EBADF and instead raises a
'system-error' for this.  This commit adjusts for 2.2.

* guix/zlib.scm (close-procedure): Remove.
(make-gzip-input-port): Use 'port->fdes' instead of 'fileno'.
Use 'gzclose' instead of 'close-procedure'.
(make-gzip-output-port): Likewise.
* tests/zlib.scm ("compression/decompression pipe"): Don't check whether
PARENT is closed using 'port-closed?'.  Instead, use 'seek' on the
underlying FD and check for EBADF.
2017-03-15 15:19:53 +01:00
Ludovic Courtès 688ec13c45
zlib: Protect against non-empty port internal buffers.
* guix/zlib.scm (make-gzip-input-port)[gzfile]: Error out
if (drain-input port) returns a non-empty string.
* guix/zlib.scm (make-gzip-output-port)[gzfile]: Call 'force-output'.
2016-07-27 12:45:01 +02:00
Ludovic Courtès d00240c36e
zlib: Clarify when 'gzread!' can return zero.
* guix/zlib.scm (gzread!): Augment docstring to clarify when zero is
returned (based on reading zlib code).
(make-gzip-input-port)[read!]: Remove scary comment.
2016-07-27 12:45:01 +02:00
Ludovic Courtès 721539026d
Add (guix zlib).
* guix/zlib.scm, tests/zlib.scm: New files.
* Makefile.am (MODULES): Add guix/zlib.scm.
(SCM_TESTS): Add tests/zlib.scm.
* m4/guix.m4 (GUIX_LIBGCRYPT_LIBDIR): New macro.
* configure.ac (LIBGCRYPT_LIBDIR): Use it.  Define and substitute
'LIBZ'.
* guix/config.scm.in (%libz): New variable.
2016-07-19 00:07:12 +02:00