X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fpoller.php;h=22fdbb5e5374a016a4ec61533727782a12ac6c26;hb=b580a338f602fea96e42f988fa468d55689dd62f;hp=45dc332e1774d084d953c251a9f36a454e2629fe;hpb=df337e57d130ceb370e5269f0052254c873b27a5;p=friendica.git diff --git a/include/poller.php b/include/poller.php index 45dc332e17..22fdbb5e53 100644 --- a/include/poller.php +++ b/include/poller.php @@ -27,11 +27,18 @@ function poller_run(&$argv, &$argc){ unset($db_host, $db_user, $db_pass, $db_data); }; + $max_processes = get_config('system', 'max_processes_backend'); + if (intval($max_processes) == 0) + $max_processes = 5; + $processlist = dbm::processlist(); if ($processlist["list"] != "") { - logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG); - if ($processlist["amount"] > 5) + logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG); + + if ($processlist["amount"] > $max_processes) { + logger("Processcheck: Maximum number of processes for backend tasks (".$max_processes.") reached.", LOGGER_DEBUG); return; + } } if (poller_max_connections_reached()) @@ -70,9 +77,12 @@ function poller_run(&$argv, &$argc){ // Log the type of database processes $processlist = dbm::processlist(); if ($processlist["amount"] != "") { - logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG); - if ($processlist["amount"] > 5) + logger("Processcheck: Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG); + + if ($processlist["amount"] > $max_processes) { + logger("Processcheck: Maximum number of processes for backend tasks (".$max_processes.") reached.", LOGGER_DEBUG); return; + } } // Constantly check the number of available database connections to let the frontend be accessible at any time @@ -218,7 +228,7 @@ function poller_max_connections_reached() { function poller_kill_stale_workers() { $r = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `executed` != '0000-00-00 00:00:00'"); - if (!is_array($r) || count($r) == 0) { + if (!dba::is_result($r)) { // No processing here needed return; }