RE: [PEAR-DEV] Re: Log and locking

From: Date: Tue, 17 Sep 2002 18:29:08 +0000
Subject: RE: [PEAR-DEV] Re: Log and locking
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-9125@lists.php.net to get a copy of this message
> On Tue, Sep 17, 2002 at 06:09:48PM +0100, Richard Heyes wrote: > > > Any particular reason Log_File doesn't use locking ? > > No, I don't believe so. Feel free to send me a patch that implements > locking, or I'll try to get to it myself later on this week. Oki here's a patch, though to be honest even without locking I couldn't manage to get a corrupt file despite having ~30 concurrent processes. Index: file.php =================================================================== RCS file: /repository/pear/Log/Log/file.php,v retrieving revision 1.5 diff -b -u -r1.5 file.php --- file.php 20 May 2002 22:51:08 -0000 1.5 +++ file.php 17 Sep 2002 18:16:49 -0000 @@ -57,6 +57,8 @@ { if (!$this->_opened) { $this->fp = fopen($this->filename, 'a'); + flock($this->fp, LOCK_EX); + fseek($this->fp, 0, SEEK_END); $this->_opened = true; } } @@ -68,6 +70,7 @@ function close() { if ($this->_opened) { + flock($this->fp, LOCK_UN); fclose($this->fp); $this->_opened = false; } -- Richard Heyes

« previous php.pear.dev (#9125) next »