mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
In the service reconnect to the database only when needed
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* set global variables
|
||||
* @var database $database
|
||||
*/
|
||||
global $database;
|
||||
|
||||
//increase limits
|
||||
set_time_limit(0);
|
||||
ini_set('max_execution_time', 0);
|
||||
@@ -131,6 +137,15 @@
|
||||
//get the messages waiting in the email queue
|
||||
while (true) {
|
||||
|
||||
//connect to the database if needed
|
||||
if (!$database->is_connected()) {
|
||||
$database->connect();
|
||||
if (!$database->is_connected()) {
|
||||
sleep(3);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//get the messages that are waiting to send
|
||||
$sql = "select * from v_email_queue ";
|
||||
$sql .= "where (email_status = 'waiting' or email_status = 'trying') ";
|
||||
@@ -139,7 +154,6 @@
|
||||
$sql .= "limit :limit ";
|
||||
$parameters['hostname'] = $hostname;
|
||||
$parameters['limit'] = $email_queue_limit;
|
||||
$database = new database;
|
||||
$email_queue = $database->select($sql, $parameters, 'all');
|
||||
unset($parameters);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user