fork conditionnel

This commit is contained in:
Rodolphe Quiedeville 2005-11-10 08:51:49 +00:00
parent 39a9f75b4e
commit 72481f4eeb

View File

@ -26,9 +26,7 @@
require ("../../master.inc.php"); require ("../../master.inc.php");
require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphContrats.class.php"); require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphContrats.class.php");
$childrenTotal = 6; $verbose = 0;
$childrenNow = 0;
$clientPerChild = 0;
$sql = "SELECT max(rowid)"; $sql = "SELECT max(rowid)";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat";
@ -36,12 +34,27 @@ $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat";
if ($db->query($sql)) if ($db->query($sql))
{ {
$row = $db->fetch_row(); $row = $db->fetch_row();
$clientPerChild = ceil($row[0] / $childrenTotal); $maxid = $row[0];
$db->free(); $db->free();
} }
while ( $childrenNow < $childrenTotal ) $fork = 0;
if ($fork == 0)
{ {
$process = new ProcessGraphContrats( 0, $maxid, $verbose );
$process->go(0, $verbose);
}
else
{
$childrenTotal = 6;
$childrenNow = 0;
$clientPerChild = 0;
$clientPerChild = ceil($row[0] / $childrenTotal);
while ( $childrenNow < $childrenTotal )
{
$pid = pcntl_fork(); $pid = pcntl_fork();
@ -55,10 +68,10 @@ while ( $childrenNow < $childrenTotal )
} }
else else
{ {
$process = new ProcessGraphContrats( $childrenNow, $clientPerChild ); $process = new ProcessGraphContrats( $childrenNow, $clientPerChild, $verbose );
$process->go(); $process->go(0, $verbose);
die(); die();
} }
}
} }
?> ?>