aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-05-07 15:54:49 -0700
committerfriendica <info@friendica.com>2012-05-07 15:54:49 -0700
commit189a31e6287781e03a874b13e27dedefe2beedf3 (patch)
treee151365d584ea12cadd06b1114492cef620cbdc4 /include
parente8b9b8a403f4b13ed1548c3a8e616cadcd65e43e (diff)
downloadvolse-hubzilla-189a31e6287781e03a874b13e27dedefe2beedf3.tar.gz
volse-hubzilla-189a31e6287781e03a874b13e27dedefe2beedf3.tar.bz2
volse-hubzilla-189a31e6287781e03a874b13e27dedefe2beedf3.zip
If a contact has had delivery issues in the last 15 minutes, send new posts straight to the queue
and don't even try to connect. Also defer polling for stuck contacts. Should reduce the number of stuck processes trying to connect with dead or dying servers significantly.
Diffstat (limited to 'include')
-rw-r--r--include/delivery.php11
-rw-r--r--include/diaspora.php18
-rw-r--r--include/onepoll.php4
-rw-r--r--include/queue_fn.php9
4 files changed, 34 insertions, 8 deletions
diff --git a/include/delivery.php b/include/delivery.php
index 28d81226a..5f84a548a 100644
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -347,7 +347,10 @@ function delivery_run($argv, $argc){
}
}
- $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ if(! was_recently_delayed($contact['id']))
+ $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ else
+ $deliver_status = (-1);
logger('notifier: dfrn_delivery returns ' . $deliver_status);
@@ -390,7 +393,11 @@ function delivery_run($argv, $argc){
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
- $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ if(! was_recently_delayed($contact['id']))
+ $deliver_status = slapper($owner,$contact['notify'],$slappy);
+ else
+ $deliver_status = (-1);
+
if($deliver_status == (-1)) {
// queue message for redelivery
add_to_queue($contact['id'],NETWORK_OSTATUS,$slappy);
diff --git a/include/diaspora.php b/include/diaspora.php
index 5069c1127..2051de5fc 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -2298,14 +2298,20 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch) {
logger('diaspora_transmit: ' . $logid . ' ' . $dest_url);
- if(! intval(get_config('system','diaspora_test')))
- post_url($dest_url . '/', $slap);
+ if(was_recently_delayed($contact['id'])) {
+ $return_code = 0;
+ }
else {
- logger('diaspora_transmit: test_mode');
- return 200;
+ if(! intval(get_config('system','diaspora_test'))) {
+ post_url($dest_url . '/', $slap);
+ $return_code = $a->get_curl_code();
+ }
+ else {
+ logger('diaspora_transmit: test_mode');
+ return 200;
+ }
}
-
- $return_code = $a->get_curl_code();
+
logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code);
if((! $return_code) || (($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))) {
diff --git a/include/onepoll.php b/include/onepoll.php
index 42bce0f68..d80bf9780 100644
--- a/include/onepoll.php
+++ b/include/onepoll.php
@@ -25,6 +25,7 @@ function onepoll_run($argv, $argc){
require_once('include/email.php');
require_once('include/socgraph.php');
require_once('include/pidfile.php');
+ require_once('include/queue_fn.php');
load_config('config');
load_config('system');
@@ -54,6 +55,9 @@ function onepoll_run($argv, $argc){
return;
}
+ if(was_recently_delayed($contact_id))
+ return;
+
$d = datetime_convert();
// Only poll from those with suitable relationships,
diff --git a/include/queue_fn.php b/include/queue_fn.php
index 3c1087f4e..613571c84 100644
--- a/include/queue_fn.php
+++ b/include/queue_fn.php
@@ -15,6 +15,15 @@ function remove_queue_item($id) {
);
}
+function was_recently_delayed($cid) {
+
+ $r = q("SELECT `id` FROM `queue` WHERE `cid` = %d
+ and last > UTC_TIMESTAMP() - interval 15 minute limit 1",
+ intval($cid)
+ );
+
+}
+
function add_to_queue($cid,$network,$msg,$batch = false) {