requeue deliveries on 503 errors which have 'retry-after' headers

This commit is contained in:
Friendika 2011-09-27 19:27:47 -07:00
parent 75af366122
commit 4f9c072d66
4 changed files with 9 additions and 2 deletions

View file

@ -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 );

View file

@ -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));
}

View file

@ -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,'<?xml') === false) {
logger('dfrn_deliver: phase 2: no valid XML returned');
logger('dfrn_deliver: phase 2: returned XML: ' . $xml, LOGGER_DATA);

View file

@ -187,6 +187,9 @@ EOT;
logger('slapper returned ' . $return_code);
if(! $return_code)
return(-1);
if(($return_code == 503) && (stristr($a->get_curl_headers(),'retry-after')))
return(-1);
return ((($return_code >= 200) && ($return_code < 300)) ? 0 : 1);
}