Cleaning opened connections

This commit is contained in:
Romain Neutron
2012-01-30 12:00:34 +01:00
parent 56fc13c5bb
commit 190b5992ff

View File

@@ -19,9 +19,11 @@ use Symfony\Component\Console\Output\OutputInterface;
class task_Scheduler class task_Scheduler
{ {
const TASKDELAYTOQUIT = 60; const TASKDELAYTOQUIT = 60;
protected $output; protected $output;
protected static $connection;
protected function log($message) protected function log($message)
{ {
@@ -47,7 +49,12 @@ class task_Scheduler
{ {
require dirname(__FILE__) . '/../../../config/connexion.inc'; require dirname(__FILE__) . '/../../../config/connexion.inc';
return new connection_pdo('appbox', $hostname, $port, $user, $password, $dbname); if (!self::$connection)
{
self::$connection = new connection_pdo ('appbox', $hostname, $port, $user, $password, $dbname);
}
return self::$connection;
} }
public function run(OutputInterface $output = null, $log_tasks = true) public function run(OutputInterface $output = null, $log_tasks = true)
@@ -523,6 +530,7 @@ class task_Scheduler
{ {
$conn->close(); $conn->close();
unset($conn); unset($conn);
self::$connection = null;
$to_reopen = true; $to_reopen = true;
} }
sleep($sleeptime); sleep($sleeptime);