Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fall back on unix-dotfile locking strategy if PKG_DBDIR is store on a network filesystem
Baptiste Daroussin committed 13 years ago
commit d4cc29669d3034ac7981b5e2a2e200254f23954d
parent d02ed7c
1 file changed +11 -0
modified libpkg/pkgdb.c
@@ -32,6 +32,7 @@
 */

#include <sys/param.h>
+
#include <sys/mount.h>

#include <assert.h>
#include <errno.h>
@@ -1003,6 +1004,7 @@ int
pkgdb_open(struct pkgdb **db_p, pkgdb_t type)
{
	struct pkgdb	*db = NULL;
+
	struct statfs	 stfs;
	bool		 reopen = false;
	char		 localpath[MAXPATHLEN + 1];
	const char	*dbdir = NULL;
@@ -1061,6 +1063,15 @@ pkgdb_open(struct pkgdb **db_p, pkgdb_t type)
			return (EPKG_FATAL);

		sqlite3_initialize();
+

+
		/*
+
		 * Fall back on unix-dotfile locking strategy if on a network filesystem
+
		 */
+
		if (statfs(dbdir, &stfs) == 0) {
+
			if ((stfs.f_flags & MNT_LOCAL) != MNT_LOCAL)
+
				sqlite3_vfs_register(sqlite3_vfs_find("unix-dotfile"), 1);
+
		}
+

		if (sqlite3_open(localpath, &db->sqlite) != SQLITE_OK) {
			ERROR_SQLITE(db->sqlite);
			pkgdb_close(db);