Changeset: 39dd5b05c975 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/39dd5b05c975
Modified Files:
        gdk/gdk_bbp.c
Branch: Jul2021
Log Message:

Move declaration to end of file to protect against accidental use.


diffs (85 lines):

diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -270,40 +270,6 @@ static volatile MT_Id locked_by = 0;
 static int BBPunloadCnt = 0;
 static MT_Lock GDKunloadLock = MT_LOCK_INITIALIZER(GDKunloadLock);
 
-/* GDKtmLock protects all accesses and changes to BAKDIR and SUBDIR
- * must use BBPtmlock()/BBPtmunlock() to set/unset the lock */
-static MT_Lock GDKtmLock = MT_LOCK_INITIALIZER(GDKtmLock);
-static char *lockfile;
-static int lockfd;
-
-void
-BBPtmlock(void)
-{
-       MT_lock_set(&GDKtmLock);
-       if (GDKinmemory(0))
-               return;
-       /* also use an external lock file to synchronize with external
-        * programs */
-       if (lockfile == NULL) {
-               lockfile = GDKfilepath(0, NULL, ".tm_lock", NULL);
-               if (lockfile == NULL)
-                       return;
-       }
-       lockfd = MT_lockf(lockfile, F_LOCK);
-}
-
-void
-BBPtmunlock(void)
-{
-       if (lockfile && lockfd >= 0) {
-               assert(!GDKinmemory(0));
-               MT_lockf(lockfile, F_ULOCK);
-               close(lockfd);
-               lockfd = -1;
-       }
-       MT_lock_unset(&GDKtmLock);
-}
-
 void
 BBPlock(void)
 {
@@ -4374,3 +4340,40 @@ gdk_bbp_reset(void)
        backup_dir = 0;
        backup_subdir = 0;
 }
+
+/* GDKtmLock protects all accesses and changes to BAKDIR and SUBDIR.
+ * MUST use BBPtmlock()/BBPtmunlock() to set/unset the lock.
+ *
+ * This is at the end of the file on purpose: we don't want people to
+ * accidentally use GDKtmLock directly. */
+static MT_Lock GDKtmLock = MT_LOCK_INITIALIZER(GDKtmLock);
+static char *lockfile;
+static int lockfd;
+
+void
+BBPtmlock(void)
+{
+       MT_lock_set(&GDKtmLock);
+       if (GDKinmemory(0))
+               return;
+       /* also use an external lock file to synchronize with external
+        * programs */
+       if (lockfile == NULL) {
+               lockfile = GDKfilepath(0, NULL, ".tm_lock", NULL);
+               if (lockfile == NULL)
+                       return;
+       }
+       lockfd = MT_lockf(lockfile, F_LOCK);
+}
+
+void
+BBPtmunlock(void)
+{
+       if (lockfile && lockfd >= 0) {
+               assert(!GDKinmemory(0));
+               MT_lockf(lockfile, F_ULOCK);
+               close(lockfd);
+               lockfd = -1;
+       }
+       MT_lock_unset(&GDKtmLock);
+}
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to