require_once('include/items.php');
require_once('include/bbcode.php');
require_once('include/socgraph.php');
+require_once('include/cache.php');
function queue_run(&$argv, &$argc){
global $a;
- if ($argc > 1)
+ if ($argc > 1) {
$queue_id = intval($argv[1]);
- else
+ } else {
$queue_id = 0;
+ }
+
+ $cachekey_deadguy = 'queue_run:deadguy:';
+ $cachekey_server = 'queue_run:server:';
if (!$queue_id) {
if ($r) {
foreach ($r as $rr) {
logger('Removing expired queue item for ' . $rr['name'] . ', uid=' . $rr['uid']);
- logger('Expired queue data :' . $rr['content'], LOGGER_DATA);
+ logger('Expired queue data: ' . $rr['content'], LOGGER_DATA);
}
q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
}
call_hooks('queue_predeliver', $a, $r);
- if (dbm::is_result) {
+ if (dbm::is_result($r)) {
foreach ($r as $q_item) {
logger('Call queue for id '.$q_item['id']);
proc_run(PRIORITY_LOW, "include/queue.php", $q_item['id']);
return;
}
+ $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']);
+ return;
+ }
+
$server = poco_detect_server($c[0]['url']);
if ($server != "") {
- logger("Check server ".$server." (".$c[0]["network"].")");
+ $vital = Cache::get($cachekey_server.$server);
- if (!poco_check_server($server, $c[0]["network"], true)) {
+ if (is_null($vital)) {
+ logger("Check server ".$server." (".$c[0]["network"].")");
+
+ $vital = poco_check_server($server, $c[0]["network"], true);
+ Cache::set($cachekey_server.$server, $vital, CACHE_QUARTER_HOUR);
+ }
+
+ if (!is_null($vital) AND !$vital) {
logger('queue: skipping dead server: '.$server);
update_queue_time($q_item['id']);
return;
if ($deliver_status == (-1)) {
update_queue_time($q_item['id']);
+ Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
remove_queue_item($q_item['id']);
}
if ($deliver_status == (-1)) {
update_queue_time($q_item['id']);
+ Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
remove_queue_item($q_item['id']);
}
if ($deliver_status == (-1)) {
update_queue_time($q_item['id']);
+ Cache::set($cachekey_deadguy.$contact['notify'], true, CACHE_QUARTER_HOUR);
} else {
remove_queue_item($q_item['id']);
}
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
call_hooks('queue_deliver', $a, $params);
- if ($params['result'])
+ if ($params['result']) {
remove_queue_item($q_item['id']);
- else
+ } else {
update_queue_time($q_item['id']);
-
+ }
break;
}
- logger('Deliver status '.$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
+ logger('Deliver status '.(int)$deliver_status.' for item '.$q_item['id'].' to '.$contact['name'].' <'.$contact['url'].'>');
return;
}