summaryrefslogtreecommitdiff
path: root/inc/subscription.php
diff options
context:
space:
mode:
authorMichael Hamann <michael@content-space.de>2011-02-06 18:36:24 +0100
committerMichael Hamann <michael@content-space.de>2011-02-06 18:36:24 +0100
commit412b5df14aaa2104af3d82e77380c5321cd94389 (patch)
tree95cfa9f83a0d93963ad68a85fb17e12c1ffa36fa /inc/subscription.php
parente8188911ccbdab0473f7deef630d2083fd8fe44a (diff)
downloadrpg-412b5df14aaa2104af3d82e77380c5321cd94389.tar.gz
rpg-412b5df14aaa2104af3d82e77380c5321cd94389.tar.bz2
Prevent infinite loop in the subscription lock
There is no reason why the subscription should wait for other calls because the lock is only for one page so once the other call has finished the work has already been done. This simplifies the lock mechanism so there is no more loop.
Diffstat (limited to 'inc/subscription.php')
-rw-r--r--inc/subscription.php19
1 files changed, 10 insertions, 9 deletions
diff --git a/inc/subscription.php b/inc/subscription.php
index 1b5476553..8e3a99a8f 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -50,18 +50,19 @@ function subscription_lock_filename ($id){
}
function subscription_lock($id) {
- // FIXME merge this with the indexer lock generation, abstract out
global $conf;
$lock = subscription_lock_filename($id);
- while(!@mkdir($lock,$conf['dmode'])){
- usleep(50);
- if(time()-@filemtime($lock) > 60*5){
- // looks like a stale lock - remove it
- @rmdir($lock);
- }else{
- return false;
- }
+
+ if (is_dir($lock) && time()-@filemtime($lock) > 60*5) {
+ // looks like a stale lock - remove it
+ @rmdir($lock);
}
+
+ // try creating the lock directory
+ if (!@mkdir($lock,$conf['dmode'])) {
+ return false;
+ }
+
if($conf['dperm']) chmod($lock, $conf['dperm']);
return true;
}