Error handling with Compress::Zlib
From: Mark Seger (Mark.Seger_at_hp.com)
Date: 10/21/04
- Next message: Gerhard M: "Re: Regex, how do I replace quotation pairs into <LI> & </LI>?"
- Previous message: lakely: "Program errors after module updates"
- Next in thread: Jim Keenan: "Re: Error handling with Compress::Zlib"
- Reply: Jim Keenan: "Re: Error handling with Compress::Zlib"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 21 Oct 2004 11:26:48 -0400
I have a script that periodically copies a number of files from /proc to
a zipped file using this library. It's been working fine for over a
year and I've recently encountered a corrupted file. My first question
has to do with how the thing got corrupted in the first place and the
second question is why don't I get an immediate error when hitting the
corrputed data.
Now for some details.
Writing the file I simply do a
$file=Compress::Zlib::gzopen($filename,'ab') or error-handling-here
$file->gzwrite($data) or error-handling-here
periodically I flush the buffer with
$file->gzflush(2);
I don't report any errors when writing the file, but I also just noticed
on closer inspection that I'm not checking the return status from flush.
Could that be my problem? groan...
If I try to gunzip the file, it fails with a message that the file is
corrupted. If I zcat the file and redirect the output to another file,
I get a couple errors that the file is corrupted but it does continue
processing. However, the resultant file is clearly corruputed midway
through. If I read the file with gzreadline it eventually returns an
error, but not before returning a whole pile of corrupted records. Does
this mean that the data buffer was corrupted (maybe by gzflush) but
successfully compressed?
Is corruption related to the way I'm doing the flushing and if so what
could I have done to prevent this? Assuming I did trap the error (which
I will definately add to my code) is there a clean way to recover? My
current thought is I should just close the file and reopen a newer version?
-mark
- Next message: Gerhard M: "Re: Regex, how do I replace quotation pairs into <LI> & </LI>?"
- Previous message: lakely: "Program errors after module updates"
- Next in thread: Jim Keenan: "Re: Error handling with Compress::Zlib"
- Reply: Jim Keenan: "Re: Error handling with Compress::Zlib"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|