sqlite3: Enabling option to disable filesystem locking (POSIX advisory locks)
When sqlite database is expected to be stored on a NFS disk (e.g., a
home directory and ~/.ndnx/ndnsec-public-info.db is on NFS mount),
default POSIX advisory filesystem locks may not work properly, since
some NFS implementation do not support them. This commit allows
specification of ``--without-sqlite-locking`` to use alternative
"dotfile" sqlite locking mechanism.
Change-Id: Iddee82c6ca7839f993147547f61c440184689043
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index 7e6f4c8..43dc641 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -88,9 +88,16 @@
{
boost::filesystem::path identityDir = boost::filesystem::path(getenv("HOME")) / ".ndnx";
boost::filesystem::create_directories (identityDir);
-
- int res = sqlite3_open((identityDir / "ndnsec-public-info.db").c_str(), &m_database);
+ /// @todo Add define for windows/unix in wscript. The following may completely fail on windows
+ int res = sqlite3_open_v2((identityDir / "ndnsec-public-info.db").c_str(), &m_database,
+ SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
+#ifdef DISABLE_SQLITE3_FS_LOCKING
+ "unix-dotfile"
+#else
+ 0
+#endif
+ );
if (res != SQLITE_OK)
throw Error("identity DB cannot be opened/created");