Merge pull request #1253 from annando/1412-performance-improvement
Performance improvements when polling contacts
This commit is contained in:
commit
546e2809e9
|
@ -2028,6 +2028,7 @@ function diaspora_retraction($importer,$xml) {
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
|
delete_thread($r[0]['id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2100,6 +2101,7 @@ function diaspora_signed_retraction($importer,$xml,$msg) {
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
|
delete_thread($r[0]['id']);
|
||||||
|
|
||||||
// Now check if the retraction needs to be relayed by us
|
// Now check if the retraction needs to be relayed by us
|
||||||
//
|
//
|
||||||
|
|
|
@ -948,7 +948,12 @@ function add_page_info_data($data) {
|
||||||
function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
|
function add_page_info($url, $no_photos = false, $photo = "", $keywords = false, $keyword_blacklist = "") {
|
||||||
require_once("mod/parse_url.php");
|
require_once("mod/parse_url.php");
|
||||||
|
|
||||||
$data = parseurl_getsiteinfo($url, true);
|
$data = Cache::get("parse_url:".$url);
|
||||||
|
if (is_null($data)){
|
||||||
|
$data = parseurl_getsiteinfo($url, true);
|
||||||
|
Cache::set("parse_url:".$url,serialize($data));
|
||||||
|
} else
|
||||||
|
$data = unserialize($data);
|
||||||
|
|
||||||
if ($photo != "")
|
if ($photo != "")
|
||||||
$data["images"][0]["src"] = $photo;
|
$data["images"][0]["src"] = $photo;
|
||||||
|
|
|
@ -15,7 +15,7 @@ function onepoll_run(&$argv, &$argc){
|
||||||
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");
|
||||||
|
@ -57,28 +57,30 @@ function onepoll_run(&$argv, &$argc){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test
|
|
||||||
$lockpath = get_lockpath();
|
$lockpath = get_lockpath();
|
||||||
if ($lockpath != '') {
|
if ($lockpath != '') {
|
||||||
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
|
$pidfile = new pidfile($lockpath, 'onepoll'.$contact_id);
|
||||||
if($pidfile->is_already_running()) {
|
if ($pidfile->is_already_running()) {
|
||||||
logger("onepoll: Already running for contact ".$contact_id);
|
logger("onepoll: Already running for contact ".$contact_id);
|
||||||
|
if ($pidfile->running_time() > 9*60) {
|
||||||
|
$pidfile->kill();
|
||||||
|
logger("killed stale process");
|
||||||
|
}
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$d = datetime_convert();
|
$d = datetime_convert();
|
||||||
|
|
||||||
// Only poll from those with suitable relationships,
|
// Only poll from those with suitable relationships,
|
||||||
// and which have a polling address and ignore Diaspora since
|
// and which have a polling address and ignore Diaspora since
|
||||||
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
|
// we are unable to match those posts with a Diaspora GUID and prevent duplicates.
|
||||||
|
|
||||||
$contacts = q("SELECT `contact`.* FROM `contact`
|
$contacts = q("SELECT `contact`.* FROM `contact`
|
||||||
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
|
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
|
||||||
AND NOT `network` IN ( '%s', '%s', '%s' )
|
AND NOT `network` IN ( '%s', '%s', '%s' )
|
||||||
AND `contact`.`id` = %d
|
AND `contact`.`id` = %d
|
||||||
AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
|
AND `self` = 0 AND `contact`.`blocked` = 0 AND `contact`.`readonly` = 0
|
||||||
AND `contact`.`archive` = 0 LIMIT 1",
|
AND `contact`.`archive` = 0 LIMIT 1",
|
||||||
intval(CONTACT_IS_SHARING),
|
intval(CONTACT_IS_SHARING),
|
||||||
intval(CONTACT_IS_FRIEND),
|
intval(CONTACT_IS_FRIEND),
|
||||||
|
|
|
@ -240,14 +240,14 @@ function poller_run(&$argv, &$argc){
|
||||||
// We should be getting everything via a hub. But just to be sure, let's check once a day.
|
// We should be getting everything via a hub. But just to be sure, let's check once a day.
|
||||||
// (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
|
// (You can make this more or less frequent if desired by setting 'pushpoll_frequency' appropriately)
|
||||||
// This also lets us update our subscription to the hub, and add or replace hubs in case it
|
// This also lets us update our subscription to the hub, and add or replace hubs in case it
|
||||||
// changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
// changed. We will only update hubs once a day, regardless of 'pushpoll_frequency'.
|
||||||
|
|
||||||
|
|
||||||
if($contact['subhub']) {
|
if($contact['subhub']) {
|
||||||
$poll_interval = get_config('system','pushpoll_frequency');
|
$poll_interval = get_config('system','pushpoll_frequency');
|
||||||
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
$contact['priority'] = (($poll_interval !== false) ? intval($poll_interval) : 3);
|
||||||
$hub_update = false;
|
$hub_update = false;
|
||||||
|
|
||||||
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
|
if((datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) || $force)
|
||||||
$hub_update = true;
|
$hub_update = true;
|
||||||
}
|
}
|
||||||
|
@ -256,13 +256,13 @@ function poller_run(&$argv, &$argc){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on $contact['priority'], should we poll this site now? Or later?
|
* Based on $contact['priority'], should we poll this site now? Or later?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch ($contact['priority']) {
|
switch ($contact['priority']) {
|
||||||
case 5:
|
case 5:
|
||||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month"))
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 month"))
|
||||||
$update = true;
|
$update = true;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week"))
|
if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 week"))
|
||||||
$update = true;
|
$update = true;
|
||||||
|
@ -285,7 +285,13 @@ function poller_run(&$argv, &$argc){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
proc_run('php','include/onepoll.php',$contact['id']);
|
// Don't run onepoll.php if the contact isn't pollable
|
||||||
|
// This check also is inside the onepoll.php - but this will reduce the load
|
||||||
|
if (in_array($contact["rel"], array(CONTACT_IS_SHARING, CONTACT_IS_FRIEND)) AND ($contact["poll"] != "")
|
||||||
|
AND !in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_FACEBOOK, NETWORK_PUMPIO, NETWORK_TWITTER, NETWORK_APPNET))
|
||||||
|
AND !$contact["self"] AND !$contact["blocked"] AND !$contact["readonly"] AND !$contact["archive"])
|
||||||
|
proc_run('php','include/onepoll.php',$contact['id']);
|
||||||
|
|
||||||
if($interval)
|
if($interval)
|
||||||
@time_sleep_until(microtime(true) + (float) $interval);
|
@time_sleep_until(microtime(true) + (float) $interval);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue