g2 Wed, 15 Jul 2009 20:59:08 +0000 URL: http://svn.php.net/viewvc?view=revision&revision=284147
Changed paths: U php/phpruntests/trunk/src/taskScheduler/rtTaskSchedulerFile.php Log: minor bugifx to avoid warning Modified: php/phpruntests/trunk/src/taskScheduler/rtTaskSchedulerFile.php =================================================================== --- php/phpruntests/trunk/src/taskScheduler/rtTaskSchedulerFile.php 2009-07-15 19:16:58 UTC (rev 284146) +++ php/phpruntests/trunk/src/taskScheduler/rtTaskSchedulerFile.php 2009-07-15 20:59:08 UTC (rev 284147) @@ -21,6 +21,18 @@ private $groupTasks = false; // are the tasks stored in groups? + /** + * the signal-handler is called by the interrupt- or quit-signal. this is + * necessary to cleanup the tmp files and terminate the script correct. + * + * @param int $signal + */ + public static function signalHandler($signal) + { + exit(0); + } + + /** * sets the task-list which has to be an array of task-objects. * it's also possible to use a multidimensional array. in this case the @@ -33,7 +45,7 @@ */ public function setTaskList(array $taskList) { - if (is_array($taskList[0])) { + if (isset($taskList[0]) && is_array($taskList[0])) { $this->groupTasks = true; $this->processCount = sizeof($taskList); } @@ -77,6 +89,7 @@ $this->processCount = sizeof($this->taskList); } + // distribute the task to the children $this->distributeTasks(); @@ -99,7 +112,12 @@ break; } } + + // register signal-handler + pcntl_signal(SIGINT, "rtTaskSchedulerFile::signalHandler"); + pcntl_signal(SIGQUIT, "rtTaskSchedulerFile::signalHandler"); + // wait until all child-processes are terminated for ($i=0; $i<$this->processCount; $i++) { pcntl_waitpid($this->pidStore[$i], $status); @@ -160,16 +178,16 @@ $response = explode("[END]", $response); array_pop($response); - foreach ($response as $resultList) { + foreach ($response as $testGroupResults) { - $resultList = unserialize($resultList); + $testGroupResults = unserialize($testGroupResults); - if ($resultList === false) { + if ($testGroupResults === false) { print "ERROR unserialize - receiver $cid\n"; continue; } - - $this->resultList = array_merge($this->resultList, $resultList); + + $this->resultList[] = $testGroupResults; } unlink(self::TMP_FILE.$cid); @@ -194,6 +212,8 @@ foreach ($taskList as $task) { + $s = microtime(true); + $task = unserialize($task); if ($task === false) { @@ -202,8 +222,15 @@ } $task->run(); + + $e = microtime(true); + $results = $task->getResult(); + if (isset($results[0]) && is_object($results[0])) { + $results[0]->setTime($e-$s); + } + rtTestOutputWriter::flushResult($results, $this->reportStatus, $cid); $response = serialize($results)."[END]";
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php