summaryrefslogtreecommitdiff
path: root/lib/parallelizingdaemon.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parallelizingdaemon.php')
-rw-r--r--lib/parallelizingdaemon.php12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/parallelizingdaemon.php b/lib/parallelizingdaemon.php
index 5ecfd98f3..dc28b5643 100644
--- a/lib/parallelizingdaemon.php
+++ b/lib/parallelizingdaemon.php
@@ -87,7 +87,7 @@ class ParallelizingDaemon extends Daemon
function run()
{
if (isset($this->_debug)) {
- echo $this->name() . " - debugging output enabled.\n";
+ echo $this->name() . " - Debugging output enabled.\n";
}
do {
@@ -107,9 +107,10 @@ class ParallelizingDaemon extends Daemon
if ($pid) {
// Parent
+
if (isset($this->_debug)) {
echo $this->name() .
- " (parent) forked new child - pid $pid.\n";
+ " - Forked new child - pid $pid.\n";
}
@@ -120,22 +121,25 @@ class ParallelizingDaemon extends Daemon
// Child
// Do something with each object
+
$this->childTask($o);
exit();
}
// Remove child from ps list as it finishes
+
while (($c = pcntl_wait($status, WNOHANG OR WUNTRACED)) > 0) {
if (isset($this->_debug)) {
- echo $this->name() . " child $c finished.\n";
+ echo $this->name() . " - Child $c finished.\n";
}
$this->removePs($this->_children, $c);
}
// Wait! We have too many damn kids.
+
if (sizeof($this->_children) >= $this->_max_children) {
if (isset($this->_debug)) {
@@ -158,7 +162,7 @@ class ParallelizingDaemon extends Daemon
while (($c = pcntl_wait($status, WUNTRACED)) > 0) {
if (isset($this->_debug)) {
- echo $this->name() . " child $c finished.\n";
+ echo $this->name() . " - Child $c finished.\n";
}
$this->removePs($this->_children, $c);