From 4f9c072d661939680bd26b366b3c248d94a3b8da Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 27 Sep 2011 19:27:47 -0700 Subject: [PATCH] requeue deliveries on 503 errors which have 'retry-after' headers --- boot.php | 2 +- include/diaspora.php | 3 ++- include/items.php | 3 +++ include/salmon.php | 3 +++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/boot.php b/boot.php index 2e58f88d9..24f965283 100644 --- a/boot.php +++ b/boot.php @@ -8,7 +8,7 @@ require_once("include/pgettext.php"); require_once('include/nav.php'); define ( 'FRIENDIKA_PLATFORM', 'Free Friendika'); -define ( 'FRIENDIKA_VERSION', '2.3.1116' ); +define ( 'FRIENDIKA_VERSION', '2.3.1117' ); define ( 'DFRN_PROTOCOL_VERSION', '2.21' ); define ( 'DB_UPDATE_VERSION', 1092 ); diff --git a/include/diaspora.php b/include/diaspora.php index 5b51314ac..1ae8ca800 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1267,7 +1267,7 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch) { $return_code = $a->get_curl_code(); logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code); - if(! $return_code) { + if((! $return_code) || (($curl_stat == 503) && (stristr($a->get_curl_headers(),'retry-after')))) { logger('diaspora_transmit: queue message'); // queue message for redelivery q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`,`batch`) @@ -1280,5 +1280,6 @@ function diaspora_transmit($owner,$contact,$slap,$public_batch) { ); } + return(($return_code) ? $return_code : (-1)); } diff --git a/include/items.php b/include/items.php index da5a18cad..a1baf7471 100644 --- a/include/items.php +++ b/include/items.php @@ -1042,6 +1042,9 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if((! $curl_stat) || (! strlen($xml))) return(-1); // timed out + if(($curl_stat == 503) && (stristr($a->get_curl_headers(),'retry-after'))) + return(-1); + if(strpos($xml,'get_curl_headers(),'retry-after'))) + return(-1); + return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1); }