From 070b0f87a0c85c2751804a56d3e167ad6bea2dd7 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sun, 8 Jan 2012 21:52:32 +0000 Subject: [PATCH] * Improved error message for LockServerDaemon when parameters are missing and bumped default 'maxClients' value. --- maintenance/locking/LockServerDaemon.php | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/maintenance/locking/LockServerDaemon.php b/maintenance/locking/LockServerDaemon.php index a6bde69433..2cb6eb2e1a 100644 --- a/maintenance/locking/LockServerDaemon.php +++ b/maintenance/locking/LockServerDaemon.php @@ -58,6 +58,15 @@ class LockServerDaemon { if ( self::$instance ) { throw new Exception( 'LockServer already initialized.' ); } + foreach ( array( 'address', 'port', 'authKey' ) as $par ) { + if ( !isset( $config[$par] ) ) { + die( "Usage: php LockServerDaemon.php " . + "--address
--port --authkey " . + "[--connTimeout ] [--lockTimeout ] " . + "[--maxLocks ] [--maxClients ] [--maxBacklog ]" + ); + } + } self::$instance = new self( $config ); return self::$instance; } @@ -66,17 +75,11 @@ class LockServerDaemon { * @params $config Array */ protected function __construct( array $config ) { - $required = array( 'address', 'port', 'authKey' ); - foreach ( $required as $par ) { - if ( !isset( $config[$par] ) ) { - throw new Exception( "Parameter '$par' must be specified." ); - } - } - + // Required parameters... $this->address = $config['address']; $this->port = $config['port']; $this->authKey = $config['authKey']; - + // Parameters with defaults... $connTimeout = isset( $config['connTimeout'] ) ? $config['connTimeout'] : 1.5; @@ -92,7 +95,7 @@ class LockServerDaemon { : 5000; $this->maxClients = isset( $config['maxClients'] ) ? $config['maxClients'] - : 100; + : 1000; // less than default FD_SETSIZE $this->maxBacklog = isset( $config['maxBacklog'] ) ? $config['maxBacklog'] : 10; -- 2.20.1