summaryrefslogtreecommitdiff
path: root/includes/ForkController.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
committerPierre Schmitz <pierre@archlinux.de>2010-07-28 11:52:48 +0200
commit222b01f5169f1c7e69762e0e8904c24f78f71882 (patch)
tree8e932e12546bb991357ec48eb1638d1770be7a35 /includes/ForkController.php
parent00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff)
update to MediaWiki 1.16.0
Diffstat (limited to 'includes/ForkController.php')
-rw-r--r--includes/ForkController.php24
1 files changed, 14 insertions, 10 deletions
diff --git a/includes/ForkController.php b/includes/ForkController.php
index 09e1788b..7b889228 100644
--- a/includes/ForkController.php
+++ b/includes/ForkController.php
@@ -2,10 +2,12 @@
/**
* Class for managing forking command line scripts.
- * Currently just does forking and process control, but it could easily be extended
+ * Currently just does forking and process control, but it could easily be extended
* to provide IPC and job dispatch.
*
* This class requires the posix and pcntl extensions.
+ *
+ * @ingroup Maintenance
*/
class ForkController {
var $children = array();
@@ -39,13 +41,13 @@ class ForkController {
}
/**
- * Start the child processes.
+ * Start the child processes.
*
- * This should only be called from the command line. It should be called
+ * This should only be called from the command line. It should be called
* as early as possible during execution.
*
- * This will return 'child' in the child processes. In the parent process,
- * it will run until all the child processes exit or a TERM signal is
+ * This will return 'child' in the child processes. In the parent process,
+ * it will run until all the child processes exit or a TERM signal is
* received. It will then return 'done'.
*/
public function start() {
@@ -73,16 +75,18 @@ class ForkController {
// Restart if the signal was abnormal termination
// Don't restart if it was deliberately killed
$signal = pcntl_wtermsig( $status );
- if ( in_array( $signal, self::$restartableSignals ) ) {
+ if ( in_array( $signal, self::$restartableSignals ) ) {
echo "Worker exited with signal $signal, restarting\n";
$this->procsToStart++;
}
} elseif ( pcntl_wifexited( $status ) ) {
// Restart on non-zero exit status
$exitStatus = pcntl_wexitstatus( $status );
- if ( $exitStatus > 0 ) {
+ if ( $exitStatus != 0 ) {
echo "Worker exited with status $exitStatus, restarting\n";
$this->procsToStart++;
+ } else {
+ echo "Worker exited normally\n";
}
}
}
@@ -96,7 +100,7 @@ class ForkController {
if ( function_exists( 'pcntl_signal_dispatch' ) ) {
pcntl_signal_dispatch();
} else {
- declare (ticks=1) { $status = $status; }
+ declare (ticks=1) { $status = $status; }
}
// Respond to TERM signal
if ( $this->termReceived ) {
@@ -123,7 +127,7 @@ class ForkController {
*/
protected function forkWorkers( $numProcs ) {
global $wgMemc, $wgCaches, $wgMainCacheType;
-
+
$this->prepareEnvironment();
// Create the child processes
@@ -151,7 +155,7 @@ class ForkController {
global $wgMemc, $wgMainCacheType;
$wgMemc = wfGetCache( $wgMainCacheType );
$this->children = null;
- pcntl_signal( SIGTERM, SIG_DFL );
+ pcntl_signal( SIGTERM, SIG_DFL );
}
protected function handleTermSignal( $signal ) {