Marius Cramer
2014-09-26 132081c0e69f0313ccb0d23637499e940d29f470
- added check for mysql error to avoid flood of error messages/mails
4 files modified
35 ■■■■■ changed files
server/cron_daily.php 2 ●●●●● patch | view | raw | blame | history
server/lib/app.inc.php 18 ●●●●● patch | view | raw | blame | history
server/lib/classes/db_mysql.inc.php 13 ●●●●● patch | view | raw | blame | history
server/server.php 2 ●●●●● patch | view | raw | blame | history
server/cron_daily.php
@@ -32,6 +32,8 @@
require SCRIPT_PATH."/lib/config.inc.php";
require SCRIPT_PATH."/lib/app.inc.php";
$app->setCaller('cron_daily');
set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE);
server/lib/app.inc.php
@@ -35,6 +35,7 @@
    var $loaded_modules = array();
    var $loaded_plugins = array();
    var $_calling_script = '';
    function __construct() {
@@ -60,6 +61,23 @@
    }
    function setCaller($caller) {
        $this->_calling_script = $caller;
    }
    function getCaller() {
        return $this->_calling_script;
    }
    function forceErrorExit($errmsg = 'undefined') {
        global $conf;
        if($this->_calling_script == 'server') {
            @unlink($conf['temppath'] . $conf['fs_div'] . '.ispconfig_lock');
        }
        die('Exiting because of error: ' . $errmsg);
    }
    function uses($classes) {
        global $conf;
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 {
server/server.php
@@ -31,6 +31,8 @@
require SCRIPT_PATH."/lib/config.inc.php";
require SCRIPT_PATH."/lib/app.inc.php";
$app->setCaller('server');
set_time_limit(0);
ini_set('error_reporting', E_ALL & ~E_NOTICE);