aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2014-10-21 13:27:33 +1100
committerRedMatrix <info@friendica.com>2014-10-21 13:27:33 +1100
commitbcb4356fe03a5f4ba31319ab95f574e56d528cd5 (patch)
tree1e04f37f37d171aaf62f44e13456665d2298709c /include
parent577d84b883b52dde84c18c659a8c4674abe4e94e (diff)
parent58431f948eb5e1d23548b537fdb92dea7d79e196 (diff)
downloadvolse-hubzilla-bcb4356fe03a5f4ba31319ab95f574e56d528cd5.tar.gz
volse-hubzilla-bcb4356fe03a5f4ba31319ab95f574e56d528cd5.tar.bz2
volse-hubzilla-bcb4356fe03a5f4ba31319ab95f574e56d528cd5.zip
Merge pull request #652 from beardy-unixer/master
Prevent multiple simultaneous pollers.
Diffstat (limited to 'include')
-rw-r--r--include/poller.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/poller.php b/include/poller.php
index 61298b0ab..d18cb1ca6 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 logfile. 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');
@@ -375,7 +384,10 @@ function poller_run($argv, $argc){
}
}
}
-
+
+ //All done - clear the lockfile
+ @unlink($lockfile);
+
return;
}