mozilla-sqlite-nfs.patch
branchesr10
changeset 570 bcc669f726e5
equal deleted inserted replaced
561:9139b0467f6c 570:bcc669f726e5
       
     1 # HG changeset patch
       
     2 # Parent 7854b317f3c3258c89887b3fbd5f88509445c8e5
       
     3 # User Martin Stransky <stransky@redhat.com>
       
     4 Bug 433129 - nfs hosted profiles/browsers result in broken search and history, r=asuth
       
     5 
       
     6 diff --git a/storage/src/TelemetryVFS.cpp b/storage/src/TelemetryVFS.cpp
       
     7 --- a/storage/src/TelemetryVFS.cpp
       
     8 +++ b/storage/src/TelemetryVFS.cpp
       
     9 @@ -34,20 +34,31 @@
       
    10   * and other provisions required by the GPL or the LGPL. If you do not delete
       
    11   * the provisions above, a recipient may use your version of this file under
       
    12   * the terms of any one of the MPL, the GPL or the LGPL.
       
    13   *
       
    14   * ***** END LICENSE BLOCK ***** */
       
    15  
       
    16  #include <string.h>
       
    17  #include "mozilla/Telemetry.h"
       
    18 +#include "mozilla/Preferences.h"
       
    19  #include "sqlite3.h"
       
    20  #include "nsThreadUtils.h"
       
    21  #include "mozilla/Util.h"
       
    22  
       
    23 +/**
       
    24 + * This preference is a workaround to allow users/sysadmins to identify
       
    25 + * that the profile exists on an NFS share whose implementation
       
    26 + * is incompatible with SQLite's default locking implementation.
       
    27 + * Bug 433129 attempted to automatically identify such file-systems, 
       
    28 + * but a reliable way was not found and it was determined that the fallback 
       
    29 + * locking is slower than POSIX locking, so we do not want to do it by default.
       
    30 +*/
       
    31 +#define PREF_NFS_FILESYSTEM   "storage.nfs_filesystem"
       
    32 +
       
    33  namespace {
       
    34  
       
    35  using namespace mozilla;
       
    36  
       
    37  struct Histograms {
       
    38    const char *name;
       
    39    const Telemetry::ID readB;
       
    40    const Telemetry::ID writeB;
       
    41 @@ -463,23 +474,33 @@ xNextSystemCall(sqlite3_vfs *vfs, const 
       
    42  }
       
    43  
       
    44  namespace mozilla {
       
    45  namespace storage {
       
    46  
       
    47  sqlite3_vfs* ConstructTelemetryVFS()
       
    48  {
       
    49  #if defined(XP_WIN)
       
    50 -#define EXPECTED_VFS "win32"
       
    51 +#define EXPECTED_VFS     "win32"
       
    52 +#define EXPECTED_VFS_NFS "win32"
       
    53  #else
       
    54 -#define EXPECTED_VFS "unix"
       
    55 +#define EXPECTED_VFS     "unix"
       
    56 +#define EXPECTED_VFS_NFS "unix-excl"
       
    57  #endif
       
    58 -
       
    59 -  sqlite3_vfs *vfs = sqlite3_vfs_find(NULL);
       
    60 -  const bool expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS);
       
    61 +  
       
    62 +  bool expected_vfs;
       
    63 +  sqlite3_vfs *vfs;
       
    64 +  if (Preferences::GetBool(PREF_NFS_FILESYSTEM)) {
       
    65 +    vfs = sqlite3_vfs_find(EXPECTED_VFS_NFS);
       
    66 +    expected_vfs = (vfs != nsnull);
       
    67 +  }
       
    68 +  else {
       
    69 +    vfs = sqlite3_vfs_find(NULL);
       
    70 +    expected_vfs = vfs->zName && !strcmp(vfs->zName, EXPECTED_VFS);
       
    71 +  }
       
    72    if (!expected_vfs) {
       
    73      return NULL;
       
    74    }
       
    75  
       
    76    sqlite3_vfs *tvfs = new ::sqlite3_vfs;
       
    77    memset(tvfs, 0, sizeof(::sqlite3_vfs));
       
    78    tvfs->iVersion = 3;
       
    79    // If the SQLite VFS version is updated, this shim must be updated as well.