From: Aaron Schulz Date: Wed, 18 Jul 2012 20:43:36 +0000 (-0700) Subject: [LockManager] Made LSLockManager session 32 chars (128 bits). X-Git-Tag: 1.31.0-rc.0~22989^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=fa0e2e615dcddb50bc8ef067227c7b71091916f8;p=lhc%2Fweb%2Fwiklou.git [LockManager] Made LSLockManager session 32 chars (128 bits). Change-Id: I1eba3eb44ebef02c771b518c2bcbdc0d41eb8086 --- diff --git a/includes/filerepo/backend/lockmanager/LSLockManager.php b/includes/filerepo/backend/lockmanager/LSLockManager.php index 024e11b717..894281828c 100644 --- a/includes/filerepo/backend/lockmanager/LSLockManager.php +++ b/includes/filerepo/backend/lockmanager/LSLockManager.php @@ -57,14 +57,14 @@ class LSLockManager extends QuorumLockManager { * Construct a new instance from configuration. * * $config paramaters include: - * 'lockServers' : Associative array of server names to configuration. - * Configuration is an associative array that includes: - * 'host' - IP address/hostname - * 'port' - TCP port - * 'authKey' - Secret string the lock server uses - * 'srvsByBucket' : Array of 1-16 consecutive integer keys, starting from 0, - * each having an odd-numbered list of server names (peers) as values. - * 'connTimeout' : Lock server connection attempt timeout. [optional] + * - lockServers : Associative array of server names to configuration. + * Configuration is an associative array that includes: + * - host : IP address/hostname + * - port : TCP port + * - authKey : Secret string the lock server uses + * - srvsByBucket : Array of 1-16 consecutive integer keys, starting from 0, + * each having an odd-numbered list of server names (peers) as values. + * - connTimeout : Lock server connection attempt timeout. [optional] * * @param Array $config */ @@ -82,7 +82,7 @@ class LSLockManager extends QuorumLockManager { $this->connTimeout = 3; // use some sane amount } - $this->session = wfRandomString( 31 ); + $this->session = wfRandomString( 32 ); // 128 bits } /** diff --git a/maintenance/locking/LockServerDaemon.php b/maintenance/locking/LockServerDaemon.php index ba778f453b..689c93092d 100644 --- a/maintenance/locking/LockServerDaemon.php +++ b/maintenance/locking/LockServerDaemon.php @@ -239,7 +239,7 @@ class LockServerDaemon { list( $session, $key, $command, $type, $values ) = $m; if ( sha1( $session . $command . $type . $values . $this->authKey ) !== $key ) { return 'BAD_KEY'; - } elseif ( strlen( $session ) !== 31 ) { + } elseif ( strlen( $session ) !== 32 ) { return 'BAD_SESSION'; } $values = explode( '|', $values ); @@ -272,7 +272,7 @@ class LockServerDaemon { /** * Remove a socket's corresponding session from tracking and * store it in the dead session tracking if it still has locks. - * + * * @param $socket resource * @return bool */ @@ -309,7 +309,7 @@ class LockServerDaemon { /** * Get the current timestamp and memory usage - * + * * @return string */ protected function stat() { @@ -479,10 +479,10 @@ class LockHolder { /** * @param $session string - * @return bool + * @return bool */ public function sessionHasLocks( $session ) { - return isset( $this->sessionIndexSh[$session] ) + return isset( $this->sessionIndexSh[$session] ) || isset( $this->sessionIndexEx[$session] ); }