1

I'm been going crazy on this one...

I've been using the gzflush() function for years in my collectl tool and recently noticed something very unusual with it on debian. I'm actually thinking it's more the fact that it's a newer version of Zlib.

The problem seems to be the functionality changed somewhere along the way and while I can code around the multiple versions I'd first like ask others if they've seen this themselves or know for a fact what exactly is going on.

Specifically, if I create 2 compressed files and immediately gzflush them with a value of 2, which equates to Z_SYNC_FLUSH, it works fine. But if I then try to flush them a second time, at least on debian running zlib V2.02, it fails. The identical code works fine on rhel5.2 and zlib V1.42.

As long as I don't try to flush a file that has already been flushed, the debian version seems to be ok, but I'm finding this very annoying and wondering if it's anything I'm doing wrong?

here's my reproducer:

#!/usr/bin/perl -w

use Compress::Zlib;

printf "%d %d %d %d %d\n", Z_FINISH, Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, Z_BLOCK;

#require "Compress/Zlib.pm";

$aaa=Compress::Zlib::gzopen("/tmp/foo.gz", 'ab') or die "flush error";
$bbb=Compress::Zlib::gzopen("/tmp/foo.gz", 'ab') or die "flush error";

$m=2;
print "Flush AAA\n";
$aaa-> gzflush($m)<0 and error($aaa);
print "Flush BBB\n";
$bbb->gzflush($m)<0 and error($bbb);

print "Flush AAA\n";
$aaa-> gzflush($m)<0 and error($bbb);
print "Flush BBB\n";
$bbb->gzflush($m)<0 and error($bbb);

sub error
{ printf "Flush error reason: %s\n", $_[0]->gzerror(); $_[0]->gzclose(); exit; }

running this on debian I see this:

./test.pl
4 0 2 3 5
Flush AAA
Flush BBB
Flush AAA
Flush error reason: buffer error

while the same script on my earlier rhel system does this. I did notice the symbol Z_BLOCK isn't defined on the earlier version so removed it from the print statement in the beginning:

./test.pl
4 0 2 3
Flush AAA
Flush BBB
Flush AAA
Flush BBB

1 Answers1

1

Just to let folks know, I've swapped email with the author of Compress::Zlib and he confirmed this is a bug he will be addressing in a future release. -mark