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
|
//Check Traffic-Lock
|
||||||
$TrafficLock = dirname($lockfile)."/froxlor_cron_traffic.lock";
|
if(function_exists('pcntl_fork')) {
|
||||||
if(file_exists($TrafficLock) && is_numeric($TrafficPid=file_get_contents($TrafficLock))) {
|
$TrafficLock = dirname($lockfile)."/froxlor_cron_traffic.lock";
|
||||||
|
if(file_exists($TrafficLock) && is_numeric($TrafficPid=file_get_contents($TrafficLock))) {
|
||||||
if(function_exists('posix_kill')) {
|
if(function_exists('posix_kill')) {
|
||||||
$TrafficPidStatus = @posix_kill($TrafficPid,0);
|
$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");
|
fwrite($debugHandler,"Traffic Run already in progress\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Create Traffic Log and Fork
|
//Create Traffic Log and Fork
|
||||||
$TrafficPid = pcntl_fork();
|
$TrafficPid = pcntl_fork();
|
||||||
if($TrafficPid) { //Parent
|
if($TrafficPid) { //Parent
|
||||||
file_put_contents($TrafficLock,$TrafficPid);
|
file_put_contents($TrafficLock,$TrafficPid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
elseif($TrafficPid == 0) { //Child
|
elseif($TrafficPid == 0) { //Child
|
||||||
posix_setsid();
|
posix_setsid();
|
||||||
fclose($debugHandler);
|
fclose($debugHandler);
|
||||||
$debugHandler = fopen("/tmp/froxlor_traffic.log","w");
|
$debugHandler = fopen("/tmp/froxlor_traffic.log","w");
|
||||||
@@ -51,9 +52,13 @@ elseif($TrafficPid == 0) { //Child
|
|||||||
$db->close();
|
$db->close();
|
||||||
unset($db);
|
unset($db);
|
||||||
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']); //detabase handler renewal after fork()
|
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']); //detabase handler renewal after fork()
|
||||||
}
|
}
|
||||||
else { //Fork failed
|
else { //Fork failed
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fwrite($debugHandler,"PHP compiled without pcntl. Not forking traffic-cron, this may take a long time!");
|
||||||
}
|
}
|
||||||
|
|
||||||
openRootDB($debugHandler, $lockfile);
|
openRootDB($debugHandler, $lockfile);
|
||||||
@@ -520,6 +525,8 @@ $db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = UNIX_TIMESTAMP()
|
|||||||
|
|
||||||
closeRootDB();
|
closeRootDB();
|
||||||
|
|
||||||
die();
|
if(function_exists('pcntl_fork')) {
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user