cvs: php4 /pear/PEAR Registry.php

From: Date: Tue, 09 Apr 2002 14:00:07 +0000
Subject: cvs: php4 /pear/PEAR Registry.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-3185@lists.php.net to get a copy of this message
alexmerz Tue Apr 9 10:00:07 2002 EDT Modified files: /php4/pear/PEAR Registry.php Log: Win95/98/Me doesn't support locking, please check patch on other systems Index: php4/pear/PEAR/Registry.php diff -u php4/pear/PEAR/Registry.php:1.24 php4/pear/PEAR/Registry.php:1.25 --- php4/pear/PEAR/Registry.php:1.24 Tue Apr 9 09:11:51 2002 +++ php4/pear/PEAR/Registry.php Tue Apr 9 10:00:05 2002 @@ -16,7 +16,7 @@ // | Author: Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: Registry.php,v 1.24 2002/04/09 13:11:51 cox Exp $ +// $Id: Registry.php,v 1.25 2002/04/09 14:00:05 alexmerz Exp $ require_once "System.php"; require_once "PEAR.php"; @@ -208,34 +208,36 @@ */ function _lock($mode = LOCK_EX) { - if ($mode != LOCK_UN && is_resource($this->lock_fp)) { - // XXX does not check type of lock (LOCK_SH/LOCK_EX) - return true; - } - if (PEAR::isError($err = $this->_assertStateDir())) { - return $err; - } - $open_mode = 'w'; - // XXX People reported problems with LOCK_SH and 'w' - if ($mode === LOCK_SH) { - if (@!is_file($this->lockfile)) { - touch($this->lockfile); - } - $open_mode = 'r'; - } - $this->lock_fp = @fopen($this->lockfile, $open_mode); - if (!is_resource($this->lock_fp)) { - return $this->raiseError("could not create lock file: $php_errormsg"); - } - if (!(int)flock($this->lock_fp, $mode)) { - switch ($mode) { - case LOCK_SH: $str = 'shared'; break; - case LOCK_EX: $str = 'exclusive'; break; - case LOCK_UN: $str = 'unlock'; break; - default: $str = 'unknown'; break; + if(!strstr(php_uname(), 'Windows 95/98')) { + if ($mode != LOCK_UN && is_resource($this->lock_fp)) { + // XXX does not check type of lock (LOCK_SH/LOCK_EX) + return true; + } + if (PEAR::isError($err = $this->_assertStateDir())) { + return $err; + } + $open_mode = 'w'; + // XXX People reported problems with LOCK_SH and 'w' + if ($mode === LOCK_SH) { + if (@!is_file($this->lockfile)) { + touch($this->lockfile); + } + $open_mode = 'r'; + } + $this->lock_fp = @fopen($this->lockfile, $open_mode); + if (!is_resource($this->lock_fp)) { + return $this->raiseError("could not create lock file: $php_errormsg"); + } + if (!(int)flock($this->lock_fp, $mode)) { + switch ($mode) { + case LOCK_SH: $str = 'shared'; break; + case LOCK_EX: $str = 'exclusive'; break; + case LOCK_UN: $str = 'unlock'; break; + default: $str = 'unknown'; break; + } + return $this->raiseError("could not acquire $str lock ($this->lockfile)", + PEAR_REGISTRY_ERROR_LOCK); } - return $this->raiseError("could not acquire $str lock ($this->lockfile)", - PEAR_REGISTRY_ERROR_LOCK); } return true; }

« previous php.pear.cvs (#3185) next »