From 132081c0e69f0313ccb0d23637499e940d29f470 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Fri, 26 Sep 2014 11:57:38 -0400 Subject: [PATCH] - added check for mysql error to avoid flood of error messages/mails --- server/lib/classes/db_mysql.inc.php | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/server/lib/classes/db_mysql.inc.php b/server/lib/classes/db_mysql.inc.php index d8bfbea..6d42847 100644 --- a/server/lib/classes/db_mysql.inc.php +++ b/server/lib/classes/db_mysql.inc.php @@ -130,6 +130,8 @@ } public function query($queryString) { + global $app; + if($this->isConnected == false) return false; $try = 0; do { @@ -138,6 +140,17 @@ if(!$ok) { if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { $this->updateError('DB::query -> reconnect'); + if($this->errorNumber == '111') { + // server is not available + if($try > 9) { + if(isset($app) && isset($app->forceErrorExit)) { + $app->forceErrorExit('Database connection failure!'); + } + // if we reach this, the app object is missing or has no exit method, so we continue as normal + } + sleep(30); // additional seconds, please! + } + if($try > 9) { return false; } else { -- Gitblit v1.9.1