Changeset: a632152f205a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a632152f205a
Modified Files:
gdk/gdk_utils.c
Branch: embedded
Log Message:
Post-merge compilation fixes
diffs (68 lines):
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1369,31 +1369,26 @@ MT_Lock GDKtmLock MT_LOCK_INITIALIZER("G
static void
GDKlockHome(void)
{
+ int fd;
+ struct stat st;
+ str gdklockpath = GDKfilepath(0, NULL, GDKLOCK, NULL);
+ char GDKdirStr[PATHLENGTH];
- //str gdklockpath = GDKfilepath(0, NULL, GDKLOCK, NULL);
-
assert(GDKlockFile == NULL);
+ assert(GDKdbpathStr != NULL);
+
+ snprintf(GDKdirStr, PATHLENGTH, "%s%c", GDKdbpathStr, DIR_SEP);
/*
- * Go there and obtain the global database lock.
+ * Obtain the global database lock.
*/
- if (chdir(GDKdbpathStr) < 0) {
- char GDKdirStr[PATHLENGTH];
-
- /* The DIR_SEP at the end of the path is needed for a
- * successful call to GDKcreatedir */
- snprintf(GDKdirStr, PATHLENGTH, "%s%c", GDKdbpathStr, DIR_SEP);
- if (GDKcreatedir(GDKdirStr) != GDK_SUCCEED)
- GDKfatal("GDKlockHome: could not create %s\n",
GDKdbpathStr);
- if (chdir(GDKdbpathStr) < 0)
- GDKfatal("GDKlockHome: could not move to %s\n",
GDKdbpathStr);
- IODEBUG fprintf(stderr, "#GDKlockHome: created directory %s\n",
GDKdbpathStr);
+ if (stat(GDKdbpathStr, &st) < 0 && GDKcreatedir(GDKdirStr) !=
GDK_SUCCEED) {
+ GDKfatal("GDKlockHome: could not create %s\n", GDKdbpathStr);
}
- if ((fd = MT_lockf(GDKLOCK, F_TLOCK, 4, 1)) < 0) {
+ if ((fd = MT_lockf(gdklockpath, F_TLOCK, 4, 1)) < 0) {
GDKfatal("GDKlockHome: Database lock '%s' denied\n", GDKLOCK);
}
/* now we have the lock on the database */
-
if ((GDKlockFile = fdopen(fd, "r+")) == NULL) {
close(fd);
GDKfatal("GDKlockHome: Could not open %s\n", GDKLOCK);
@@ -1412,16 +1407,20 @@ GDKlockHome(void)
GDKfatal("GDKlockHome: Could not truncate %s\n", GDKLOCK);
fflush(GDKlockFile);
GDKlog(GDKLOGON);
+ GDKfree(gdklockpath);
}
+
static void
GDKunlockHome(void)
{
+ str gdklockpath = GDKfilepath(0, NULL, GDKLOCK, NULL);
if (GDKlockFile) {
- MT_lockf(GDKLOCK, F_ULOCK, 4, 1);
+ MT_lockf(gdklockpath, F_ULOCK, 4, 1);
fclose(GDKlockFile);
GDKlockFile = 0;
}
+ GDKfree(gdklockpath);
}
/*
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list