Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question

closed as off topic by SvW, Ward, Iain Nov 17 '12 at 17:13

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 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

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.