]> git.mxchange.org Git - friendica.git/commitdiff
Poller: Use the processlist when the number of maximum database connections was provi...
authorMichael Vogel <icarus@dabo.de>
Thu, 11 Feb 2016 10:33:45 +0000 (11:33 +0100)
committerMichael Vogel <icarus@dabo.de>
Thu, 11 Feb 2016 10:33:45 +0000 (11:33 +0100)
include/poller.php

index 03f030771229e2b4cb7965777f4351e980b1ac2f..9976e76db2cd619b85f171eeaa72fd2fb7721a42 100644 (file)
@@ -131,21 +131,28 @@ function poller_max_connections_reached() {
                return false;
 
        // Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
+       // In that case we use the processlist to determine the current number of connections
        $max = get_config("system", "max_connections");
 
        if ($max == 0) {
                $max = intval($r[0]["Value"]);
                if ($max == 0)
                        return false;
-       }
 
-       $r = q("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
-       if (!$r)
-               return false;
+               $r = q("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
+               if (!$r)
+                       return false;
 
-       $connected = intval($r[0]["Value"]);
-       if ($connected == 0)
-               return false;
+               $connected = intval($r[0]["Value"]);
+               if ($connected == 0)
+                       return false;
+       } else {
+               $r = q("SHOW PROCESSLIST");
+               if (!$r)
+                       return false;
+
+               $connected = count($r);
+       }
 
        $level = $connected / $max;