Changeset: 41f6c17be35f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=41f6c17be35f Branch: mmt Log Message:
merged with oct diffs (108 lines): diff --git a/cmake/monetdb-defines.cmake b/cmake/monetdb-defines.cmake --- a/cmake/monetdb-defines.cmake +++ b/cmake/monetdb-defines.cmake @@ -70,7 +70,6 @@ function(monetdb_configure_defines) # Linux specific, in the future, it might be ported to other platforms check_symbol_exists("fallocate" "fcntl.h" HAVE_FALLOCATE) check_function_exists("fcntl" HAVE_FCNTL) - check_symbol_exists("F_GETLK" "fcntl.h" HAVE_F_GETLK) check_symbol_exists("fork" "unistd.h" HAVE_FORK) check_symbol_exists("fsync" "unistd.h" HAVE_FSYNC) check_symbol_exists("ftime" "sys/timeb.h" HAVE_FTIME) diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c --- a/common/utils/msabaoth.c +++ b/common/utils/msabaoth.c @@ -681,39 +681,6 @@ msab_getMyStatus(sabdb** ret) #define MAINTENANCEFILE ".maintenance" -#ifndef WIN32 -/* returns pid of the process holding the gdk lock, or 0 if that is not possible. - * 'not possible' could be for a variety of reasons. - */ -static pid_t -MT_get_locking_pid(const char *filename) -{ -#if !defined(HAVE_FCNTL) || !defined(HAVE_F_GETLK) - (void)filename; - return 0; -#else - int fd; - struct flock fl = { - .l_type = F_WRLCK, - .l_whence = SEEK_SET, - .l_start = 4, - .l_len = 1, - }; - pid_t pid = 0; - - fd = open(filename, O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) - return 0; - - if (fcntl(fd, F_GETLK, &fl) == 0) - pid = fl.l_pid; - - close(fd); - return pid; -#endif -} -#endif - static sabdb * msab_getSingleStatus(const char *pathbuf, const char *dbname, sabdb *next) { @@ -732,11 +699,9 @@ msab_getSingleStatus(const char *pathbuf return next; sdb = malloc(sizeof(sabdb)); - *sdb = (sabdb) { 0 }; - sdb->uplog = NULL; - sdb->uri = NULL; - sdb->secret = NULL; - sdb->next = next; + *sdb = (sabdb) { + .next = next, + }; /* store the database name */ snprintf(buf, sizeof(buf), "%s/%s", pathbuf, dbname); @@ -788,8 +753,13 @@ msab_getSingleStatus(const char *pathbuf sdb->state = SABdbInactive; } else if (fd == -1) { #ifndef WIN32 - /* file is locked, so mserver is running. can we find it? */ - sdb->pid = MT_get_locking_pid(buf); + /* extract process ID from lock file */ + if ((f = fopen(buf, "r")) != NULL) { + int pid; + if (fscanf(f, "USR=%*d PID=%d TIME=", &pid) == 1) + sdb->pid = pid; + fclose(f); + } #endif /* see if the database has finished starting */ snprintf(buf, sizeof(buf), "%s/%s/%s", pathbuf, dbname, STARTEDFILE); diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -1184,7 +1184,7 @@ GDKlockHome(int farmid) assert(BBPfarms[farmid].dirname != NULL); assert(BBPfarms[farmid].lock_file == NULL); - if(!(gdklockpath = GDKfilepath(farmid, NULL, GDKLOCK, NULL))) { + if ((gdklockpath = GDKfilepath(farmid, NULL, GDKLOCK, NULL)) == NULL) { return GDK_FAIL; } diff --git a/monetdb_config.h.in b/monetdb_config.h.in --- a/monetdb_config.h.in +++ b/monetdb_config.h.in @@ -116,7 +116,6 @@ #cmakedefine HAVE_DISPATCH_SEMAPHORE_CREATE 1 #cmakedefine HAVE_FALLOCATE 1 #cmakedefine HAVE_FCNTL 1 -#cmakedefine HAVE_F_GETLK 1 #cmakedefine HAVE_FORK 1 #cmakedefine HAVE_FSYNC 1 #cmakedefine HAVE_FTIME 1 _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list