aboutsummaryrefslogtreecommitdiffstats
path: root/include/notifier.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-22 22:07:47 -0800
committerfriendica <info@friendica.com>2014-01-22 22:07:47 -0800
commit66baa3cab0537a5a2f1a4aad54526b35987da90d (patch)
tree0c397e38389b4abed4bbd2f6e59eb0c2c3e8c36e /include/notifier.php
parent39142002238b416a2d823245cf046ca9eee0bf94 (diff)
downloadvolse-hubzilla-66baa3cab0537a5a2f1a4aad54526b35987da90d.tar.gz
volse-hubzilla-66baa3cab0537a5a2f1a4aad54526b35987da90d.tar.bz2
volse-hubzilla-66baa3cab0537a5a2f1a4aad54526b35987da90d.zip
try to reduce the number of simulaneous deliveries of the same post when dealing with owner relays that have more than one channel instance. If things melt down in the next few hours and I'm not available please revert this. I've reviewed a few times and think it's OK, but this part of the delivery code is traditionally touchy.
Diffstat (limited to 'include/notifier.php')
-rw-r--r--include/notifier.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/notifier.php b/include/notifier.php
index 0868ac77e..81f971107 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -425,8 +425,28 @@ function notifier_run($argv, $argc){
$sql_extra = (($private) ? "" : " or hubloc_url = '" . dbesc(z_root()) . "' ");
- $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc
- where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
+
+ if($relay_to_owner && (! $private) && ($cmd !== 'relay')) {
+
+ // If sending a followup to the post owner, only send it to one channel clone - to avoid race conditions.
+ // In this case we'll pick the most recently contacted hub, as their primary might be down and the most
+ // recently contacted has the best chance of being alive.
+
+ // For private posts or uplinks we have to do things differently as only the sending clone will have the recipient list.
+ // We have to send to all clone channels of the owner to find out who has the definitive list. Posts with
+ // item_private set (but no ACL list) will return empty recipients (except for the sender and owner) in
+ // collect_recipients() above. The end result is we should get only one delivery per delivery chain if we
+ // aren't the owner or author.
+
+
+ $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc
+ where hubloc_hash in (" . implode(',',$recipients) . ") group by hubloc_sitekey order by hubloc_connected desc limit 1");
+ }
+ else {
+ $r = q("select hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc
+ where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
+ }
+
if(! $r) {
logger('notifier: no hubs');
return;