From 67da2f2a3da70a72ba9622dc4aa187a18d3eee1c Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Wed, 26 Mar 2025 11:30:34 -0600 Subject: [PATCH] Make sure the database connection is available --- app/xml_cdr/resources/service/xml_cdr.php | 28 ++++++++++++----------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/app/xml_cdr/resources/service/xml_cdr.php b/app/xml_cdr/resources/service/xml_cdr.php index b39fd75333..3eb64013b9 100644 --- a/app/xml_cdr/resources/service/xml_cdr.php +++ b/app/xml_cdr/resources/service/xml_cdr.php @@ -46,7 +46,7 @@ if (file_exists($file)) { $pid = file_get_contents($file); if (function_exists('posix_getsid')) { - if (posix_getsid($pid) === false) { + if (posix_getsid($pid) === false) { //process is not running $exists = false; } @@ -84,12 +84,12 @@ //$interval = $settings->get('xml_cdr', '$interval'); //make sure the /var/run/fusionpbx directory exists - if (!file_exists('/var/run/fusionpbx')) { - $result = mkdir('/var/run/fusionpbx', 0777, true); - if (!$result) { - die('Failed to create /var/run/fusionpbx'); - } - } + if (!file_exists('/var/run/fusionpbx')) { + $result = mkdir('/var/run/fusionpbx', 0777, true); + if (!$result) { + die('Failed to create /var/run/fusionpbx'); + } + } //create the process id file if the process doesn't exist if (!$pid_exists) { @@ -110,20 +110,22 @@ file_put_contents($pid_file, getmypid()); } - - //import the call detail records from HTTP POST or file system $cdr = new xml_cdr; //get the cdr record $xml_cdr_dir = $settings->get('switch', 'log').'/xml_cdr'; -//loop through +//service loop while (true) { - //import the call detail records from HTTP POST or file system - if (!$cdr) { - $cdr = new xml_cdr; + //make sure the database connection is available + while (!$database->is_connected()) { + //connect to the database + $database->connect(); + + //sleep for a moment + usleep(100000); } //find and process cdr records