]> git.mxchange.org Git - friendica.git/blobdiff - include/poller.php
API: use regex instead of SimpleXMLElement
[friendica.git] / include / poller.php
index 45dc332e1774d084d953c251a9f36a454e2629fe..d134f30d0fac270001d5cac8d9e98bc1411d81d7 100644 (file)
@@ -11,7 +11,6 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
 }
 
 require_once("boot.php");
-require_once("dbm.php");
 
 function poller_run(&$argv, &$argc){
        global $a, $db;
@@ -27,12 +26,8 @@ function poller_run(&$argv, &$argc){
                unset($db_host, $db_user, $db_pass, $db_data);
        };
 
-       $processlist = dbm::processlist();
-       if ($processlist["list"] != "") {
-               logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
-               if ($processlist["amount"] > 5)
-                       return;
-       }
+       if ($a->max_processes_reached())
+               return;
 
        if (poller_max_connections_reached())
                return;
@@ -67,13 +62,9 @@ function poller_run(&$argv, &$argc){
 
        while ($r = q("SELECT * FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `created` LIMIT 1")) {
 
-               // 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)
-                               return;
-               }
+               // Constantly check the number of parallel database processes
+               if ($a->max_processes_reached())
+                       return;
 
                // Constantly check the number of available database connections to let the frontend be accessible at any time
                if (poller_max_connections_reached())
@@ -218,7 +209,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 (!dbm::is_result($r)) {
                // No processing here needed
                return;
        }