r108368 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108367‎ | r108368 | r108369 >
Date:21:52, 8 January 2012
Author:aaron
Status:ok
Tags:maintenance 
Comment:
* Improved error message for LockServerDaemon when parameters are missing and bumped default 'maxClients' value.
Modified paths:
  • /trunk/phase3/maintenance/locking/LockServerDaemon.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/locking/LockServerDaemon.php
@@ -58,6 +58,15 @@
5959 if ( self::$instance ) {
6060 throw new Exception( 'LockServer already initialized.' );
6161 }
 62+ foreach ( array( 'address', 'port', 'authKey' ) as $par ) {
 63+ if ( !isset( $config[$par] ) ) {
 64+ die( "Usage: php LockServerDaemon.php " .
 65+ "--address <address> --port <port> --authkey <key> " .
 66+ "[--connTimeout <seconds>] [--lockTimeout <seconds>] " .
 67+ "[--maxLocks <integer>] [--maxClients <integer>] [--maxBacklog <integer>]"
 68+ );
 69+ }
 70+ }
6271 self::$instance = new self( $config );
6372 return self::$instance;
6473 }
@@ -66,17 +75,11 @@
6776 * @params $config Array
6877 */
6978 protected function __construct( array $config ) {
70 - $required = array( 'address', 'port', 'authKey' );
71 - foreach ( $required as $par ) {
72 - if ( !isset( $config[$par] ) ) {
73 - throw new Exception( "Parameter '$par' must be specified." );
74 - }
75 - }
76 -
 79+ // Required parameters...
7780 $this->address = $config['address'];
7881 $this->port = $config['port'];
7982 $this->authKey = $config['authKey'];
80 -
 83+ // Parameters with defaults...
8184 $connTimeout = isset( $config['connTimeout'] )
8285 ? $config['connTimeout']
8386 : 1.5;
@@ -92,7 +95,7 @@
9396 : 5000;
9497 $this->maxClients = isset( $config['maxClients'] )
9598 ? $config['maxClients']
96 - : 100;
 99+ : 1000; // less than default FD_SETSIZE
97100 $this->maxBacklog = isset( $config['maxBacklog'] )
98101 ? $config['maxBacklog']
99102 : 10;

Status & tagging log