If no pcntl extension is found, do not fork the traffic - cron, fix by d4f, fixes #1028
Signed-off-by: Florian Aders (EleRas) <eleras@froxlor.org>
This commit is contained in:
@@ -18,8 +18,9 @@
|
||||
*/
|
||||
|
||||
//Check Traffic-Lock
|
||||
$TrafficLock = dirname($lockfile)."/froxlor_cron_traffic.lock";
|
||||
if(file_exists($TrafficLock) && is_numeric($TrafficPid=file_get_contents($TrafficLock))) {
|
||||
if(function_exists('pcntl_fork')) {
|
||||
$TrafficLock = dirname($lockfile)."/froxlor_cron_traffic.lock";
|
||||
if(file_exists($TrafficLock) && is_numeric($TrafficPid=file_get_contents($TrafficLock))) {
|
||||
if(function_exists('posix_kill')) {
|
||||
$TrafficPidStatus = @posix_kill($TrafficPid,0);
|
||||
}
|
||||
@@ -31,14 +32,14 @@ if(file_exists($TrafficLock) && is_numeric($TrafficPid=file_get_contents($Traff
|
||||
fwrite($debugHandler,"Traffic Run already in progress\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Create Traffic Log and Fork
|
||||
$TrafficPid = pcntl_fork();
|
||||
if($TrafficPid) { //Parent
|
||||
$TrafficPid = pcntl_fork();
|
||||
if($TrafficPid) { //Parent
|
||||
file_put_contents($TrafficLock,$TrafficPid);
|
||||
return 0;
|
||||
}
|
||||
elseif($TrafficPid == 0) { //Child
|
||||
}
|
||||
elseif($TrafficPid == 0) { //Child
|
||||
posix_setsid();
|
||||
fclose($debugHandler);
|
||||
$debugHandler = fopen("/tmp/froxlor_traffic.log","w");
|
||||
@@ -51,9 +52,13 @@ elseif($TrafficPid == 0) { //Child
|
||||
$db->close();
|
||||
unset($db);
|
||||
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']); //detabase handler renewal after fork()
|
||||
}
|
||||
else { //Fork failed
|
||||
}
|
||||
else { //Fork failed
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fwrite($debugHandler,"PHP compiled without pcntl. Not forking traffic-cron, this may take a long time!");
|
||||
}
|
||||
|
||||
openRootDB($debugHandler, $lockfile);
|
||||
@@ -520,6 +525,8 @@ $db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = UNIX_TIMESTAMP()
|
||||
|
||||
closeRootDB();
|
||||
|
||||
die();
|
||||
if(function_exists('pcntl_fork')) {
|
||||
die();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user