The queue now works with the cache - whoch should speed it up
This commit is contained in:
parent
ef0fb5148c
commit
9a19ae7ce1
2 changed files with 43 additions and 24 deletions
|
@ -69,7 +69,11 @@ class Probe {
|
||||||
$xrd = parse_xml_string($xml, false);
|
$xrd = parse_xml_string($xml, false);
|
||||||
|
|
||||||
if (!is_object($xrd)) {
|
if (!is_object($xrd)) {
|
||||||
$xml = fetch_url($url, false, $redirects, $xrd_timeout, "application/xrd+xml");
|
$ret = z_fetch_url($url, false, $redirects, array('timeout' => $xrd_timeout, 'accept_content' => 'application/xrd+xml'));
|
||||||
|
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$xml = $ret['body'];
|
||||||
$xrd = parse_xml_string($xml, false);
|
$xrd = parse_xml_string($xml, false);
|
||||||
}
|
}
|
||||||
if (!is_object($xrd))
|
if (!is_object($xrd))
|
||||||
|
@ -878,8 +882,13 @@ class Probe {
|
||||||
$pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
|
$pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
|
||||||
else
|
else
|
||||||
$pubkey = substr($pubkey, 5);
|
$pubkey = substr($pubkey, 5);
|
||||||
} elseif (normalise_link($pubkey) == 'http://')
|
} elseif (normalise_link($pubkey) == 'http://') {
|
||||||
$pubkey = fetch_url($pubkey);
|
$ret = z_fetch_url($pubkey);
|
||||||
|
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$pubkey = $ret['body'];
|
||||||
|
}
|
||||||
|
|
||||||
$key = explode(".", $pubkey);
|
$key = explode(".", $pubkey);
|
||||||
|
|
||||||
|
@ -899,7 +908,11 @@ class Probe {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Fetch all additional data from the feed
|
// Fetch all additional data from the feed
|
||||||
$feed = fetch_url($data["poll"]);
|
$ret = z_fetch_url($data["poll"]);
|
||||||
|
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$feed = $ret['body'];
|
||||||
$feed_data = feed_import($feed,$dummy1,$dummy2, $dummy3, true);
|
$feed_data = feed_import($feed,$dummy1,$dummy2, $dummy3, true);
|
||||||
if (!$feed_data)
|
if (!$feed_data)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -5,15 +5,16 @@ use \Friendica\Core\Config;
|
||||||
require_once("boot.php");
|
require_once("boot.php");
|
||||||
require_once('include/queue_fn.php');
|
require_once('include/queue_fn.php');
|
||||||
require_once('include/dfrn.php');
|
require_once('include/dfrn.php');
|
||||||
|
require_once('include/cache.php');
|
||||||
|
|
||||||
function queue_run(&$argv, &$argc){
|
function queue_run(&$argv, &$argc){
|
||||||
global $a, $db;
|
global $a, $db;
|
||||||
|
|
||||||
if(is_null($a)){
|
if (is_null($a)){
|
||||||
$a = new App;
|
$a = new App;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_null($db)){
|
if (is_null($db)){
|
||||||
@include(".htconfig.php");
|
@include(".htconfig.php");
|
||||||
require_once("include/dba.php");
|
require_once("include/dba.php");
|
||||||
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
$db = new dba($db_host, $db_user, $db_pass, $db_data);
|
||||||
|
@ -42,9 +43,8 @@ function queue_run(&$argv, &$argc){
|
||||||
else
|
else
|
||||||
$queue_id = 0;
|
$queue_id = 0;
|
||||||
|
|
||||||
$deadguys = array();
|
$cachekey_deadguy = 'queue_run:deadguy:';
|
||||||
$deadservers = array();
|
$cachekey_server = 'queue_run:server:';
|
||||||
$serverlist = array();
|
|
||||||
|
|
||||||
if (!$queue_id) {
|
if (!$queue_id) {
|
||||||
|
|
||||||
|
@ -133,26 +133,32 @@ function queue_run(&$argv, &$argc){
|
||||||
remove_queue_item($q_item['id']);
|
remove_queue_item($q_item['id']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(in_array($c[0]['notify'],$deadguys)) {
|
|
||||||
logger('queue: skipping known dead url: ' . $c[0]['notify']);
|
$dead = Cache::get($cachekey_deadguy.$c[0]['notify']);
|
||||||
|
|
||||||
|
if (!is_null($dead) AND $dead) {
|
||||||
|
logger('queue: skipping known dead url: '.$c[0]['notify']);
|
||||||
update_queue_time($q_item['id']);
|
update_queue_time($q_item['id']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = poco_detect_server($c[0]['url']);
|
$server = poco_detect_server($c[0]['url']);
|
||||||
|
|
||||||
if (($server != "") AND !in_array($server, $serverlist)) {
|
if ($server != "") {
|
||||||
logger("Check server ".$server." (".$c[0]["network"].")");
|
$vital = Cache::get($cachekey_server.$server);
|
||||||
if (!poco_check_server($server, $c[0]["network"], true))
|
|
||||||
$deadservers[] = $server;
|
|
||||||
|
|
||||||
$serverlist[] = $server;
|
if (is_null($vital)) {
|
||||||
}
|
logger("Check server ".$server." (".$c[0]["network"].")");
|
||||||
|
|
||||||
if (($server != "") AND in_array($server, $deadservers)) {
|
$vital = poco_check_server($server, $c[0]["network"], true);
|
||||||
logger('queue: skipping known dead server: '.$server);
|
Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
|
||||||
update_queue_time($q_item['id']);
|
}
|
||||||
continue;
|
|
||||||
|
if (!is_null($vital) AND !$vital) {
|
||||||
|
logger('queue: skipping dead server: '.$server);
|
||||||
|
update_queue_time($q_item['id']);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
|
$u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
|
||||||
|
@ -178,7 +184,7 @@ function queue_run(&$argv, &$argc){
|
||||||
|
|
||||||
if($deliver_status == (-1)) {
|
if($deliver_status == (-1)) {
|
||||||
update_queue_time($q_item['id']);
|
update_queue_time($q_item['id']);
|
||||||
$deadguys[] = $contact['notify'];
|
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||||
} else
|
} else
|
||||||
remove_queue_item($q_item['id']);
|
remove_queue_item($q_item['id']);
|
||||||
|
|
||||||
|
@ -190,7 +196,7 @@ function queue_run(&$argv, &$argc){
|
||||||
|
|
||||||
if($deliver_status == (-1)) {
|
if($deliver_status == (-1)) {
|
||||||
update_queue_time($q_item['id']);
|
update_queue_time($q_item['id']);
|
||||||
$deadguys[] = $contact['notify'];
|
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||||
} else
|
} else
|
||||||
remove_queue_item($q_item['id']);
|
remove_queue_item($q_item['id']);
|
||||||
}
|
}
|
||||||
|
@ -202,7 +208,7 @@ function queue_run(&$argv, &$argc){
|
||||||
|
|
||||||
if($deliver_status == (-1)) {
|
if($deliver_status == (-1)) {
|
||||||
update_queue_time($q_item['id']);
|
update_queue_time($q_item['id']);
|
||||||
$deadguys[] = $contact['notify'];
|
Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
|
||||||
} else
|
} else
|
||||||
remove_queue_item($q_item['id']);
|
remove_queue_item($q_item['id']);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue