aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-01-12 09:22:37 +0100
committerMario <mario@mariovavti.com>2019-01-12 09:22:37 +0100
commit9e42dfd09426e8621098d17a5eef17674345f374 (patch)
treecc2cd0c3e75509e60df76ef0f206d65a7b980452 /include/zot.php
parentf6f4e40a64c771072d0c2425e9cf2f5f42c6cd3e (diff)
parent8aa117e4ae550db2c156cec6431098700929ff5f (diff)
downloadvolse-hubzilla-9e42dfd09426e8621098d17a5eef17674345f374.tar.gz
volse-hubzilla-9e42dfd09426e8621098d17a5eef17674345f374.tar.bz2
volse-hubzilla-9e42dfd09426e8621098d17a5eef17674345f374.zip
Merge branch 'patch-20190111a' into 'dev'
FIX: memory exhaustion on zot message pickup with large message queue See merge request hubzilla/core!1466
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/include/zot.php b/include/zot.php
index 9934dae07..6d9b6aeec 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -4924,12 +4924,13 @@ function zot_reply_pickup($data) {
/*
* Everything is good if we made it here, so find all messages that are going to this location
- * and send them all.
+ * and send them all - or a reasonable number if there are a lot so we don't overflow memory.
*/
- $r = q("select * from outq where outq_posturl = '%s'",
+ $r = q("select * from outq where outq_posturl = '%s' limit 100",
dbesc($data['callback'])
);
+
if($r) {
logger('mod_zot: successful pickup message received from ' . $data['callback'] . ' ' . count($r) . ' message(s) picked up', LOGGER_DEBUG);
@@ -4955,6 +4956,19 @@ function zot_reply_pickup($data) {
}
}
+ // It's possible that we have more than 100 messages waiting to be sent.
+
+ // See if there are any more messages in the queue.
+ $x = q("select *,min(outq_created) as earliest from outq where outq_posturl = '%s'",
+ dbesc($data['callback'])
+ );
+
+ // If so, kick off a new delivery notification for the next batch
+ if ($x) {
+ logger("Send additional pickup request.", LOGGER_DEBUG);
+ queue_deliver($x[0],true);
+ }
+
// this is a bit of a hack because we don't have the hubloc_url here, only the callback url.
// worst case is we'll end up using aes256cbc if they've got a different post endpoint
@@ -4966,6 +4980,8 @@ function zot_reply_pickup($data) {
$encrypted = crypto_encapsulate(json_encode($ret),$sitekey,$algorithm);
json_return_and_die($encrypted);
+ // @FIXME: There is a possibility that the transmission will get interrupted
+ // and fail - in which case this packet of messages will be lost.
/* pickup: end */
}