* 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
*/
$this->connTimeout = 3; // use some sane amount
}
- $this->session = wfRandomString( 31 );
+ $this->session = wfRandomString( 32 ); // 128 bits
}
/**
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 );
/**
* 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
*/
/**
* Get the current timestamp and memory usage
- *
+ *
* @return string
*/
protected function stat() {
/**
* @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] );
}