]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Worker.php
Merge pull request #5794 from annando/ap1
[friendica.git] / src / Core / Worker.php
index 11dda93e373ac0b8bff41c146c80995276ba8203..3400f00ae1755229a24a20e16fc6844f1c7592c5 100644 (file)
@@ -117,12 +117,14 @@ class Worker
                                // Count active workers and compare them with a maximum value that depends on the load
                                if (self::tooMuchWorkers()) {
                                        logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
+                                       Lock::release('worker');
                                        return;
                                }
 
                                // Check free memory
                                if ($a->min_memory_reached()) {
                                        logger('Memory limit reached, quitting.', LOGGER_DEBUG);
+                                       Lock::release('worker');
                                        return;
                                }
                                Lock::release('worker');
@@ -162,7 +164,7 @@ class Worker
        {
                $condition = ["`executed` <= ? AND NOT `done`", NULL_DATE];
                $workerqueue = DBA::selectFirst('workerqueue', ['priority'], $condition, ['order' => ['priority']]);
-               if (DBA::is_result($workerqueue)) {
+               if (DBA::isResult($workerqueue)) {
                        return $workerqueue["priority"];
                } else {
                        return 0;
@@ -477,7 +479,7 @@ class Worker
                if ($max == 0) {
                        // the maximum number of possible user connections can be a system variable
                        $r = DBA::fetchFirst("SHOW VARIABLES WHERE `variable_name` = 'max_user_connections'");
-                       if (DBA::is_result($r)) {
+                       if (DBA::isResult($r)) {
                                $max = $r["Value"];
                        }
                        // Or it can be granted. This overrides the system variable
@@ -513,7 +515,7 @@ class Worker
                // We will now check for the system values.
                // This limit could be reached although the user limits are fine.
                $r = DBA::fetchFirst("SHOW VARIABLES WHERE `variable_name` = 'max_connections'");
-               if (!DBA::is_result($r)) {
+               if (!DBA::isResult($r)) {
                        return false;
                }
                $max = intval($r["Value"]);
@@ -521,7 +523,7 @@ class Worker
                        return false;
                }
                $r = DBA::fetchFirst("SHOW STATUS WHERE `variable_name` = 'Threads_connected'");
-               if (!DBA::is_result($r)) {
+               if (!DBA::isResult($r)) {
                        return false;
                }
                $used = intval($r["Value"]);
@@ -734,7 +736,7 @@ class Worker
                );
 
                // No active processes at all? Fine
-               if (!DBA::is_result($r)) {
+               if (!DBA::isResult($r)) {
                        return false;
                }
                $priorities = [];
@@ -871,7 +873,7 @@ class Worker
 
                // There can already be jobs for us in the queue.
                $r = DBA::select('workerqueue', [], ['pid' => getmypid(), 'done' => false]);
-               if (DBA::is_result($r)) {
+               if (DBA::isResult($r)) {
                        self::$db_duration += (microtime(true) - $stamp);
                        return DBA::toArray($r);
                }
@@ -1011,7 +1013,7 @@ class Worker
        {
                $command = 'bin/worker.php';
 
-               $args = [ 'cron' => $do_cron ];
+               $args = ['no_cron' => !$do_cron];
 
                get_app()->proc_run($command, $args);
 
@@ -1163,7 +1165,7 @@ class Worker
                $row = DBA::selectFirst('worker-ipc', ['jobs'], ['key' => 1]);
 
                // When we don't have a row, no job is running
-               if (!DBA::is_result($row)) {
+               if (!DBA::isResult($row)) {
                        return false;
                }