]> granicus.if.org Git - php/commitdiff
People reported problems with flock(LOCK_SH) and fopen('w')
authorTomas V.V.Cox <cox@php.net>
Mon, 1 Apr 2002 16:10:39 +0000 (16:10 +0000)
committerTomas V.V.Cox <cox@php.net>
Mon, 1 Apr 2002 16:10:39 +0000 (16:10 +0000)
pear/PEAR/Registry.php

index c09e3abddb8a83f1bffb52626804812838c914d3..fa149ee74d1058998a1a26bd4aa7997aad7720a2 100644 (file)
@@ -215,7 +215,9 @@ class PEAR_Registry extends PEAR
         if (PEAR::isError($err = $this->_assertStateDir())) {
             return $err;
         }
-        $this->lock_fp = @fopen($this->lockfile, 'w');
+        // XXX People reported problems with LOCK_SH and 'w'
+        $open_mode = ($mode === LOCK_SH) ? 'r' : 'w';
+        $this->lock_fp = @fopen($this->lockfile, $open_mode);
         if (!is_resource($this->lock_fp)) {
             return $this->raiseError("could not create lock file: $php_errormsg");
         }