]> granicus.if.org Git - php/commitdiff
Win95/98/Me doesn't support locking, please check patch on other systems
authorAlexander Merz <alexmerz@php.net>
Tue, 9 Apr 2002 14:00:05 +0000 (14:00 +0000)
committerAlexander Merz <alexmerz@php.net>
Tue, 9 Apr 2002 14:00:05 +0000 (14:00 +0000)
pear/PEAR/Registry.php

index a6c2373baa80f04ae7a6508734549c9fadea7ff9..3d84120bccd829860a060592487805d60de5ee26 100644 (file)
@@ -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;
     }