aboutsummaryrefslogtreecommitdiffstats
path: root/include/poller.php
diff options
context:
space:
mode:
authorhabeascodice <habeascodice@federated.social>2014-11-01 03:04:11 -0700
committerhabeascodice <habeascodice@federated.social>2014-11-01 03:04:11 -0700
commit31376de0665091f2dba04755562ccd238d57a13c (patch)
treeae59c8697b9fd20c33aeaf8acb3a698b63e9657b /include/poller.php
parentc854f8c238da2df08b52249142ad24ef66e422d1 (diff)
parent50c16c394fe2d966c62d30930600212a4e33303e (diff)
downloadvolse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.gz
volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.tar.bz2
volse-hubzilla-31376de0665091f2dba04755562ccd238d57a13c.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include/poller.php')
-rw-r--r--include/poller.php31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/poller.php b/include/poller.php
index 2febaeb32..f11618d37 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -25,6 +25,15 @@ function poller_run($argv, $argc){
if(! $interval)
$interval = ((get_config('system','delivery_interval') === false) ? 3 : intval(get_config('system','delivery_interval')));
+ // Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
+ $lockfile = 'store/[data]/poller';
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))) {
+ logger("poller: Already running");
+ return;
+ }
+
+ // Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
+ file_put_contents($lockfile, $x);
logger('poller: start');
@@ -254,7 +263,7 @@ function poller_run($argv, $argc){
);
- $contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_channel
+ $contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_xchan, abook_channel
FROM abook LEFT JOIN account on abook_account = account_id where 1
$sql_extra
AND (( abook_flags & %d ) OR ( abook_flags = %d ))
@@ -310,12 +319,17 @@ function poller_run($argv, $argc){
// He's dead, Jim
if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) {
- $r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d limit 1",
- intval(ABOOK_FLAG_ARCHIVED),
- intval($contact['abook_id'])
+ $n = q("select xchan_network from xchan where xchan_hash = '%s' limit 1",
+ dbesc($contact['abook_xchan'])
);
- $update = false;
- continue;
+ if($n && $n[0]['xchan_network'] == 'zot') {
+ $r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d limit 1",
+ intval(ABOOK_FLAG_ARCHIVED),
+ intval($contact['abook_id'])
+ );
+ $update = false;
+ continue;
+ }
}
if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) {
@@ -370,7 +384,10 @@ function poller_run($argv, $argc){
}
}
}
-
+
+ //All done - clear the lockfile
+ @unlink($lockfile);
+
return;
}