gzopen and locking



Hi,

I need to use gzopen and gzwrite, but I also need to lock the file
opened in order to prevent concurrent accesses.

Unfortunately, flock doesn't seem working with gzopen as I get this
error :

[25-Jan-2006 11:40:07] PHP Warning: flock(): cannot represent a stream
of type ZLIB as a File Descriptor in xxxx/gz.php4 on line 5

Is there a way to lock a file opened with gzopen ?

I tried not using flock, but after some time, the gz file is corrupted
:

zcat: xxxx.log.gz: invalid compressed data--format violated

Thanks !

.



Relevant Pages

  • Re: I cant flock, it returns 0, any ideas.
    ... > I can't flock, it returns 0, any ideas. ... You can only hold a lock on an open file. ... will fail but attempts to get another LOCK_SH lock will ... this is not how you pause the script! ...
    (comp.lang.perl.misc)
  • Re: I cant flock, it returns 0, any ideas.
    ... # returns zero when I try to flock ... >> I wanted to run this script to see if it would affect my other perl ... If someone holds a LOCK_EX lock, all attempts to get a lock will ... > the flock call will fail, and if you don't flock will just not ...
    (comp.lang.perl.misc)
  • Re: UW imap-2006b: 64 bit problem
    ... UW imapd is obliged> to do considerable more work on SVR4 systems than it does on BSD and> Linux systems which offer flock() locking as an alternative to POSIX> locking. ... IEEE Std 1003.1-1988 requires that all fcntl() locks associated with a file for a given process are removed when *any* file descriptor for that file is closed by that process. ... Put another way, before any library routine opens a file, it must be aware of what files the application and any other libraries have open and locked; otherwise the library routine will remove the lock unexpectedly when it closes the file. ...
    (comp.mail.imap)
  • flock() replacement?
    ... lock/unlock library code. ... It uses flock() to synchronize ... pthread mutex lock. ... I have tried POSIX sem lock, ...
    (comp.unix.programmer)
  • Re: flock() replacement?
    ... lock/unlock library code. ... It uses flock() to synchronize ... pthread mutex lock. ... linux 2.6, flockconsumes the most user and sys times. ...
    (comp.unix.programmer)