mozilla-sqlite-nfs.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Fri, 26 Oct 2012 23:25:51 +0200
branchesr10
changeset 570 bcc669f726e5
permissions -rw-r--r--
10.0.10esr

# HG changeset patch
# Parent 7854b317f3c3258c89887b3fbd5f88509445c8e5
# User Martin Stransky <stransky@redhat.com>
Bug 433129 - nfs hosted profiles/browsers result in broken search and history, r=asuth

diff --git a/storage/src/TelemetryVFS.cpp b/storage/src/TelemetryVFS.cpp
--- a/storage/src/TelemetryVFS.cpp
+++ b/storage/src/TelemetryVFS.cpp
@@ -34,20 +34,31 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <string.h>
 #include "mozilla/Telemetry.h"
+#include "mozilla/Preferences.h"
 #include "sqlite3.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Util.h"
 
+/**
+ * This preference is a workaround to allow users/sysadmins to identify
+ * that the profile exists on an NFS share whose implementation
+ * is incompatible with SQLite's default locking implementation.
+ * Bug 433129 attempted to automatically identify such file-systems, 
+ * but a reliable way was not found and it was determined that the fallback 
+ * locking is slower than POSIX locking, so we do not want to do it by default.
+*/
+#define PREF_NFS_FILESYSTEM   "storage.nfs_filesystem"
+
 namespace {
 
 using namespace mozilla;
 
 struct Histograms {
   const char *name;
   const Telemetry::ID readB;
   const Telemetry::ID writeB;
@@ -463,23 +474,33 @@ xNextSystemCall(sqlite3_vfs *vfs, const 
 }
 
 namespace mozilla {
 namespace storage {
 
 sqlite3_vfs* ConstructTelemetryVFS()
 {
 #if defined(XP_WIN)
-#define EXPECTED_VFS "win32"
+#define EXPECTED_VFS     "win32"
+#define EXPECTED_VFS_NFS "win32"
 #else
-#define EXPECTED_VFS "unix"
+#define EXPECTED_VFS     "unix"
+#define EXPECTED_VFS_NFS "unix-excl"
 #endif
-
-  sqlite3_vfs *vfs = sqlite3_vfs_find(NULL);
-  const bool expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS);
+  
+  bool expected_vfs;
+  sqlite3_vfs *vfs;
+  if (Preferences::GetBool(PREF_NFS_FILESYSTEM)) {
+    vfs = sqlite3_vfs_find(EXPECTED_VFS_NFS);
+    expected_vfs = (vfs != nsnull);
+  }
+  else {
+    vfs = sqlite3_vfs_find(NULL);
+    expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS);
+  }
   if (!expected_vfs) {
     return NULL;
   }
 
   sqlite3_vfs *tvfs = new ::sqlite3_vfs;
   memset(tvfs, 0, sizeof(::sqlite3_vfs));
   tvfs->iVersion = 3;
   // If the SQLite VFS version is updated, this shim must be updated as well.