From fb2924e4ac8da5a41882c314f5d9a2a21e6634e5 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 23 Sep 2010 01:24:33 +0000 Subject: [PATCH] In the past gunzip(1) write()'s after each inflate return. This is not optimal from a performance standpoint since the write buffer is not necessarily be filled up when the inflate rountine reached the end of input buffer and it's not the end of file. This problem gets uncovered by trying to pipe gunzip -c output to a GEOM device directly, which enforces the writes be multiple of sector size. Sponsored by: iXsystems, Inc. Reported by: jpaetzel MFC after: 2 weeks --- usr.bin/gzip/gzip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usr.bin/gzip/gzip.c b/usr.bin/gzip/gzip.c index 4e16bf7118b4..3f9bb4a1eda2 100644 --- a/usr.bin/gzip/gzip.c +++ b/usr.bin/gzip/gzip.c @@ -916,6 +916,8 @@ gz_uncompress(int in, int out, char *pre, size_t prelen, off_t *gsizep, switch (error) { /* Z_BUF_ERROR goes with Z_FINISH... */ case Z_BUF_ERROR: + if (z.avail_out > 0 && !done_reading) + continue; case Z_STREAM_END: case Z_OK: break;