summaryrefslogtreecommitdiff
path: root/includes/filebackend/lockmanager/MemcLockManager.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /includes/filebackend/lockmanager/MemcLockManager.php
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'includes/filebackend/lockmanager/MemcLockManager.php')
-rw-r--r--includes/filebackend/lockmanager/MemcLockManager.php50
1 files changed, 30 insertions, 20 deletions
diff --git a/includes/filebackend/lockmanager/MemcLockManager.php b/includes/filebackend/lockmanager/MemcLockManager.php
index 5eab03ee..9bb01c21 100644
--- a/includes/filebackend/lockmanager/MemcLockManager.php
+++ b/includes/filebackend/lockmanager/MemcLockManager.php
@@ -36,31 +36,31 @@
* @since 1.20
*/
class MemcLockManager extends QuorumLockManager {
- /** @var Array Mapping of lock types to the type actually used */
+ /** @var array Mapping of lock types to the type actually used */
protected $lockTypeMap = array(
self::LOCK_SH => self::LOCK_SH,
self::LOCK_UW => self::LOCK_SH,
self::LOCK_EX => self::LOCK_EX
);
- /** @var Array Map server names to MemcachedBagOStuff objects */
+ /** @var array Map server names to MemcachedBagOStuff objects */
protected $bagOStuffs = array();
- /** @var Array */
- protected $serversUp = array(); // (server name => bool)
- protected $session = ''; // string; random UUID
+ /** @var array (server name => bool) */
+ protected $serversUp = array();
+
+ /** @var string Random UUID */
+ protected $session = '';
/**
* Construct a new instance from configuration.
*
- * $config paramaters include:
+ * @param array $config Paramaters include:
* - lockServers : Associative array of server names to "<IP>:<port>" strings.
* - srvsByBucket : Array of 1-16 consecutive integer keys, starting from 0,
* each having an odd-numbered list of server names (peers) as values.
* - memcConfig : Configuration array for ObjectCache::newFromParams. [optional]
* If set, this must use one of the memcached classes.
- *
- * @param array $config
* @throws MWException
*/
public function __construct( array $config ) {
@@ -88,7 +88,7 @@ class MemcLockManager extends QuorumLockManager {
$this->session = wfRandomString( 32 );
}
- // @TODO: change this code to work in one batch
+ // @todo Change this code to work in one batch
protected function getLocksOnServer( $lockSrv, array $pathsByType ) {
$status = Status::newGood();
@@ -100,8 +100,8 @@ class MemcLockManager extends QuorumLockManager {
? array_merge( $lockedPaths[$type], $paths )
: $paths;
} else {
- foreach ( $lockedPaths as $type => $paths ) {
- $status->merge( $this->doFreeLocksOnServer( $lockSrv, $paths, $type ) );
+ foreach ( $lockedPaths as $lType => $lPaths ) {
+ $status->merge( $this->doFreeLocksOnServer( $lockSrv, $lPaths, $lType ) );
}
break;
}
@@ -110,7 +110,7 @@ class MemcLockManager extends QuorumLockManager {
return $status;
}
- // @TODO: change this code to work in one batch
+ // @todo Change this code to work in one batch
protected function freeLocksOnServer( $lockSrv, array $pathsByType ) {
$status = Status::newGood();
@@ -123,6 +123,9 @@ class MemcLockManager extends QuorumLockManager {
/**
* @see QuorumLockManager::getLocksOnServer()
+ * @param string $lockSrv
+ * @param array $paths
+ * @param string $type
* @return Status
*/
protected function doGetLocksOnServer( $lockSrv, array $paths, $type ) {
@@ -136,6 +139,7 @@ class MemcLockManager extends QuorumLockManager {
foreach ( $paths as $path ) {
$status->fatal( 'lockmanager-fail-acquirelock', $path );
}
+
return $status;
}
@@ -195,6 +199,9 @@ class MemcLockManager extends QuorumLockManager {
/**
* @see QuorumLockManager::freeLocksOnServer()
+ * @param string $lockSrv
+ * @param array $paths
+ * @param string $type
* @return Status
*/
protected function doFreeLocksOnServer( $lockSrv, array $paths, $type ) {
@@ -208,7 +215,8 @@ class MemcLockManager extends QuorumLockManager {
foreach ( $paths as $path ) {
$status->fatal( 'lockmanager-fail-releaselock', $path );
}
- return;
+
+ return $status;
}
// Fetch all the existing lock records...
@@ -254,6 +262,7 @@ class MemcLockManager extends QuorumLockManager {
/**
* @see QuorumLockManager::isServerUp()
+ * @param string $lockSrv
* @return bool
*/
protected function isServerUp( $lockSrv ) {
@@ -280,11 +289,12 @@ class MemcLockManager extends QuorumLockManager {
return null; // server appears to be down
}
}
+
return $memc;
}
/**
- * @param $path string
+ * @param string $path
* @return string
*/
protected function recordKeyForPath( $path ) {
@@ -292,27 +302,28 @@ class MemcLockManager extends QuorumLockManager {
}
/**
- * @return Array An empty lock structure for a key
+ * @return array An empty lock structure for a key
*/
protected static function newLockArray() {
return array( self::LOCK_SH => array(), self::LOCK_EX => array() );
}
/**
- * @param $a array
- * @return Array An empty lock structure for a key
+ * @param array $a
+ * @return array An empty lock structure for a key
*/
protected static function sanitizeLockArray( $a ) {
if ( is_array( $a ) && isset( $a[self::LOCK_EX] ) && isset( $a[self::LOCK_SH] ) ) {
return $a;
} else {
trigger_error( __METHOD__ . ": reset invalid lock array.", E_USER_WARNING );
+
return self::newLockArray();
}
}
/**
- * @param $memc MemcachedBagOStuff
+ * @param MemcachedBagOStuff $memc
* @param array $keys List of keys to acquire
* @return bool
*/
@@ -350,9 +361,8 @@ class MemcLockManager extends QuorumLockManager {
}
/**
- * @param $memc MemcachedBagOStuff
+ * @param MemcachedBagOStuff $memc
* @param array $keys List of acquired keys
- * @return void
*/
protected function releaseMutexes( MemcachedBagOStuff $memc, array $keys ) {
foreach ( $keys as $key ) {