summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorAdrian Lang <lang@cosmocode.de>2010-05-04 12:07:35 +0200
committerAdrian Lang <lang@cosmocode.de>2010-05-05 12:23:45 +0200
commit3e0c7aa328ac721b3bcf17822f9ed3659ad93d14 (patch)
tree725d6ccf7970a7c03ce4685f68d6d500915c4a96 /inc
parent6b8f02cfe58b224607e5479f8469dde16c3169ac (diff)
downloadrpg-3e0c7aa328ac721b3bcf17822f9ed3659ad93d14.tar.gz
rpg-3e0c7aa328ac721b3bcf17822f9ed3659ad93d14.tar.bz2
Add locking for indexer-based notifications
Diffstat (limited to 'inc')
-rw-r--r--inc/subscription.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/inc/subscription.php b/inc/subscription.php
index e5938d9bd..ce5da4cd4 100644
--- a/inc/subscription.php
+++ b/inc/subscription.php
@@ -9,6 +9,8 @@
* - subscription_set
* - get_info_subscribed
* - subscription_addresslist
+ * - subscription_lock
+ * - subscription_unlock
*
* @author Adrian Lang <lang@cosmocode.de>
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
@@ -37,6 +39,32 @@ function subscription_filename($id) {
}
/**
+ * Lock subscription info for an ID
+ *
+ * @param string $id The target page or namespace, specified by id; Namespaces
+ * are identified by appending a colon.
+ *
+ * @author Adrian Lang <lang@cosmocode.de>
+ */
+function subscription_lock($id) {
+ $lockf = subscription_filename($id) . '.lock';
+ return !file_exists($lockf) && touch($lockf);
+}
+
+/**
+ * Unlock subscription info for an ID
+ *
+ * @param string $id The target page or namespace, specified by id; Namespaces
+ * are identified by appending a colon.
+ *
+ * @author Adrian Lang <lang@cosmocode.de>
+ */
+function subscription_unlock($id) {
+ $lockf = subscription_filename($id) . '.lock';
+ return file_exists($lockf) && unlink($lockf);
+}
+
+/**
* Set subscription information
*
* Allows to set subscription informations for permanent storage in meta files.