aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Daemon/Queue.php
diff options
context:
space:
mode:
authorZotSocial Admin <zotsocial@dm42.net>2019-01-09 21:23:12 -0500
committerDM42.Net (Matt Dent) <dentm42@dm42.net>2019-01-10 13:15:00 -0500
commitb54ddccd7beece51d78b21b4ba9e98c908fec4c5 (patch)
tree0f62698180facbc95882f7ba3f0e36996e91455c /Zotlabs/Daemon/Queue.php
parentd32360cb3ec447969dcdf9f1427a4b55134dd1bb (diff)
downloadvolse-hubzilla-b54ddccd7beece51d78b21b4ba9e98c908fec4c5.tar.gz
volse-hubzilla-b54ddccd7beece51d78b21b4ba9e98c908fec4c5.tar.bz2
volse-hubzilla-b54ddccd7beece51d78b21b4ba9e98c908fec4c5.zip
FIX: memory exhaustion on exceptionally large message queues & multiple Queue.php invocations duplicate work
Diffstat (limited to 'Zotlabs/Daemon/Queue.php')
-rw-r--r--Zotlabs/Daemon/Queue.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/Zotlabs/Daemon/Queue.php b/Zotlabs/Daemon/Queue.php
index 8f529ff13..e041804f0 100644
--- a/Zotlabs/Daemon/Queue.php
+++ b/Zotlabs/Daemon/Queue.php
@@ -61,10 +61,18 @@ class Queue {
// or just prior to this query based on recent and long-term delivery history. If we have good reason to believe
// the site is permanently down, there's no reason to attempt delivery at all, or at most not more than once
// or twice a day.
-
- $r = q("SELECT * FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s ",
+
+ $r = q("SELECT *,RAND() as rn FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s order by rn limit 1",
db_utcnow()
);
+ while ($r) {
+ foreach($r as $rv) {
+ queue_deliver($rv);
+ }
+ $r = q("SELECT *,RAND() as rn FROM outq WHERE outq_delivered = 0 and outq_scheduled < %s order by rn limit 1",
+ db_utcnow()
+ );
+ }
}
if(! $r)
return;