From fa0e2e615dcddb50bc8ef067227c7b71091916f8 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 18 Jul 2012 13:43:36 -0700 Subject: [PATCH] [LockManager] Made LSLockManager session 32 chars (128 bits). Change-Id: I1eba3eb44ebef02c771b518c2bcbdc0d41eb8086 --- .../backend/lockmanager/LSLockManager.php | 18 +++++++++--------- maintenance/locking/LockServerDaemon.php | 10 +++++----- 2 files changed, 14 insertions(+), 14 deletions(-) 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] ); } -- 2.20.1