From 72481f4eeb296cf6512b830889edcc7a914e4cd0 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Thu, 10 Nov 2005 08:51:49 +0000 Subject: [PATCH] fork conditionnel --- .../script/graph-statistiques-contrats.php | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/htdocs/telephonie/script/graph-statistiques-contrats.php b/htdocs/telephonie/script/graph-statistiques-contrats.php index de7018e27a2..6e2b745f7f7 100644 --- a/htdocs/telephonie/script/graph-statistiques-contrats.php +++ b/htdocs/telephonie/script/graph-statistiques-contrats.php @@ -26,9 +26,7 @@ require ("../../master.inc.php"); require_once (DOL_DOCUMENT_ROOT."/telephonie/stats/ProcessGraphContrats.class.php"); -$childrenTotal = 6; -$childrenNow = 0; -$clientPerChild = 0; +$verbose = 0; $sql = "SELECT max(rowid)"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat"; @@ -36,29 +34,44 @@ $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat"; if ($db->query($sql)) { $row = $db->fetch_row(); - $clientPerChild = ceil($row[0] / $childrenTotal); + $maxid = $row[0]; $db->free(); } -while ( $childrenNow < $childrenTotal ) -{ - - $pid = pcntl_fork(); - - if ( $pid == -1 ) - { - die( "error\n" ); - } - elseif ( $pid == 0 ) - { - $childrenNow++; - } - else - { - $process = new ProcessGraphContrats( $childrenNow, $clientPerChild ); - $process->go(); - die(); - } -} +$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(); + + if ( $pid == -1 ) + { + die( "error\n" ); + } + elseif ( $pid == 0 ) + { + $childrenNow++; + } + else + { + $process = new ProcessGraphContrats( $childrenNow, $clientPerChild, $verbose ); + $process->go(0, $verbose); + die(); + } + } +} ?>