mirror of
https://github.com/friendica/friendica
synced 2024-12-24 16:40:15 +00:00
Merge pull request #2272 from annando/1601-queue
Queue delivery should be now more reliable
This commit is contained in:
commit
94dc1ef195
2 changed files with 45 additions and 26 deletions
|
@ -52,6 +52,8 @@ function queue_run(&$argv, &$argc){
|
|||
$queue_id = 0;
|
||||
|
||||
$deadguys = array();
|
||||
$deadservers = array();
|
||||
$serverlist = array();
|
||||
|
||||
logger('queue: start');
|
||||
|
||||
|
@ -95,7 +97,7 @@ function queue_run(&$argv, &$argc){
|
|||
// For the first 12 hours we'll try to deliver every 15 minutes
|
||||
// After that, we'll only attempt delivery once per hour.
|
||||
|
||||
$r = q("SELECT `id` FROM `queue` WHERE (( `created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ) OR ( `last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR ))");
|
||||
$r = q("SELECT `id` FROM `queue` WHERE ((`created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR && `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE) OR (`last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR)) ORDER BY `cid`, `created`");
|
||||
}
|
||||
if(! $r){
|
||||
return;
|
||||
|
@ -116,7 +118,7 @@ function queue_run(&$argv, &$argc){
|
|||
// so check again if this entry still needs processing
|
||||
|
||||
if($queue_id) {
|
||||
$qi = q("select * from queue where `id` = %d limit 1",
|
||||
$qi = q("SELECT * FROM `queue` WHERE `id` = %d LIMIT 1",
|
||||
intval($queue_id)
|
||||
);
|
||||
}
|
||||
|
@ -142,8 +144,18 @@ function queue_run(&$argv, &$argc){
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!poco_reachable($c[0]['url'])) {
|
||||
logger('queue: skipping probably dead url: ' . $c[0]['url']);
|
||||
$server = poco_detect_server($c[0]['url']);
|
||||
|
||||
if (($server != "") AND !in_array($server, $serverlist)) {
|
||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
||||
if (!poco_check_server($server, $c[0]["network"], true))
|
||||
$deadservers[] = $server;
|
||||
|
||||
$serverlist[] = $server;
|
||||
}
|
||||
|
||||
if (($server != "") AND in_array($server, $deadservers)) {
|
||||
logger('queue: skipping known dead server: '.$server);
|
||||
update_queue_time($q_item['id']);
|
||||
continue;
|
||||
}
|
||||
|
@ -166,37 +178,39 @@ function queue_run(&$argv, &$argc){
|
|||
|
||||
switch($contact['network']) {
|
||||
case NETWORK_DFRN:
|
||||
logger('queue: dfrndelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
logger('queue: dfrndelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = dfrn_deliver($owner,$contact,$data);
|
||||
|
||||
if($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
$deadguys[] = $contact['notify'];
|
||||
}
|
||||
else {
|
||||
} else
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
|
||||
break;
|
||||
case NETWORK_OSTATUS:
|
||||
if($contact['notify']) {
|
||||
logger('queue: slapdelivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
logger('queue: slapdelivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = slapper($owner,$contact['notify'],$data);
|
||||
|
||||
if($deliver_status == (-1))
|
||||
if($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
else
|
||||
$deadguys[] = $contact['notify'];
|
||||
} else
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
if($contact['notify']) {
|
||||
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
logger('queue: diaspora_delivery: item '.$q_item['id'].' for '.$contact['name'].' <'.$contact['url'].'>');
|
||||
$deliver_status = diaspora_transmit($owner,$contact,$data,$public,true);
|
||||
|
||||
if($deliver_status == (-1))
|
||||
if($deliver_status == (-1)) {
|
||||
update_queue_time($q_item['id']);
|
||||
else
|
||||
$deadguys[] = $contact['notify'];
|
||||
} else
|
||||
remove_queue_item($q_item['id']);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -212,6 +226,7 @@ function queue_run(&$argv, &$argc){
|
|||
break;
|
||||
|
||||
}
|
||||
logger('Deliver status '.$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
|
@ -796,19 +796,23 @@ function poco_check_server($server_url, $network = "", $force = false) {
|
|||
// Test for Diaspora
|
||||
$serverret = z_fetch_url($server_url);
|
||||
|
||||
$lines = explode("\n",$serverret["header"]);
|
||||
if(count($lines))
|
||||
foreach($lines as $line) {
|
||||
$line = trim($line);
|
||||
if(stristr($line,'X-Diaspora-Version:')) {
|
||||
$platform = "Diaspora";
|
||||
$version = trim(str_replace("X-Diaspora-Version:", "", $line));
|
||||
$version = trim(str_replace("x-diaspora-version:", "", $version));
|
||||
$network = NETWORK_DIASPORA;
|
||||
$versionparts = explode("-", $version);
|
||||
$version = $versionparts[0];
|
||||
if (!$serverret["success"] OR ($serverret["body"] == ""))
|
||||
$failure = true;
|
||||
else {
|
||||
$lines = explode("\n",$serverret["header"]);
|
||||
if(count($lines))
|
||||
foreach($lines as $line) {
|
||||
$line = trim($line);
|
||||
if(stristr($line,'X-Diaspora-Version:')) {
|
||||
$platform = "Diaspora";
|
||||
$version = trim(str_replace("X-Diaspora-Version:", "", $line));
|
||||
$version = trim(str_replace("x-diaspora-version:", "", $version));
|
||||
$network = NETWORK_DIASPORA;
|
||||
$versionparts = explode("-", $version);
|
||||
$version = $versionparts[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$failure) {
|
||||
|
|
Loading…
Reference in a new issue