diff options
Diffstat (limited to 'maintenance/locking/LockServerDaemon.php')
-rw-r--r-- | maintenance/locking/LockServerDaemon.php | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/maintenance/locking/LockServerDaemon.php b/maintenance/locking/LockServerDaemon.php index 1a4a928e..689c9309 100644 --- a/maintenance/locking/LockServerDaemon.php +++ b/maintenance/locking/LockServerDaemon.php @@ -1,12 +1,28 @@ <?php /** + * Simple lock server daemon that accepts lock/unlock requests. + * + * This code should not require MediaWiki setup or PHP files. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup LockManager Maintenance */ -/** - * This code should not require MediaWiki setup or PHP files. - */ if ( php_sapi_name() !== 'cli' ) { die( "This is not a valid entry point.\n" ); } @@ -223,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 ); @@ -256,9 +272,9 @@ 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 book + * @return bool */ protected function recordDeadSocket( $socket ) { $session = array_search( $socket, $this->sessions ); @@ -293,7 +309,7 @@ class LockServerDaemon { /** * Get the current timestamp and memory usage - * + * * @return string */ protected function stat() { @@ -382,7 +398,7 @@ class SocketArray { /** * @param $sock resource - * @return string|false + * @return string|bool */ public function readRcvBuffer( $sock ) { $key = array_search( $sock, $this->clients ); @@ -463,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] ); } |