diff options
author | Alexander Merz <alexmerz@php.net> | 2002-04-09 14:00:05 +0000 |
---|---|---|
committer | Alexander Merz <alexmerz@php.net> | 2002-04-09 14:00:05 +0000 |
commit | eb85e073e59f07c712a465945416056539671aad (patch) | |
tree | 352bef0a1efe845e47d1b69f8d677fa63b227b4d /pear/PEAR/Registry.php | |
parent | dc811f3041200e28c29706c05a9bcfcf432b1e1e (diff) | |
download | php-git-eb85e073e59f07c712a465945416056539671aad.tar.gz |
Win95/98/Me doesn't support locking, please check patch on other systems
Diffstat (limited to 'pear/PEAR/Registry.php')
-rw-r--r-- | pear/PEAR/Registry.php | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/pear/PEAR/Registry.php b/pear/PEAR/Registry.php index a6c2373baa..3d84120bcc 100644 --- a/pear/PEAR/Registry.php +++ b/pear/PEAR/Registry.php @@ -208,34 +208,36 @@ class PEAR_Registry extends PEAR */ 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); + 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; } - $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 (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; } |