- Upstream patch to fsync() less

This commit is contained in:
Christopher Aillon 2008-05-22 19:14:28 +00:00
commit 46e52a4848
2 changed files with 88 additions and 1 deletions

82
mozilla-fsync.patch Normal file
View file

@ -0,0 +1,82 @@
diff --git a/storage/src/mozStorageConnection.cpp b/storage/src/mozStorageConnection.cpp
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -48,6 +48,8 @@
#include "nsAutoPtr.h"
#include "nsIFile.h"
#include "nsIVariant.h"
+#include "nsIPrefService.h"
+#include "nsIPrefBranch.h"
#include "mozIStorageAggregateFunction.h"
#include "mozIStorageFunction.h"
@@ -65,6 +67,8 @@
#ifdef PR_LOGGING
PRLogModuleInfo* gStorageLog = nsnull;
#endif
+
+#define PREF_TS_SYNCHRONOUS "toolkit.storage.synchronous"
NS_IMPL_ISUPPORTS1(mozStorageConnection, mozIStorageConnection)
@@ -155,6 +159,28 @@ mozStorageConnection::Initialize(nsIFile
mDBConn = nsnull;
return ConvertResultCode(srv);
+ }
+
+ // Set the synchronous PRAGMA, according to the pref
+ nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
+ PRInt32 synchronous = 1; // Default to NORMAL if pref not set
+ if (pref)
+ (void)pref->GetIntPref(PREF_TS_SYNCHRONOUS, &synchronous);
+
+ switch (synchronous) {
+ case 2:
+ (void)ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+ "PRAGMA synchronous = FULL;"));
+ break;
+ case 0:
+ (void)ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+ "PRAGMA synchronous = OFF;"));
+ break;
+ case 1:
+ default:
+ (void)ExecuteSimpleSQL(NS_LITERAL_CSTRING(
+ "PRAGMA synchronous = NORMAL;"));
+ break;
}
return NS_OK;
diff --git a/storage/test/unit/test_storage_connection.js b/storage/test/unit/test_storage_connection.js
--- a/storage/test/unit/test_storage_connection.js
+++ b/storage/test/unit/test_storage_connection.js
@@ -197,6 +197,20 @@ function test_createTable(){
}
}
+function test_defaultSynchronousAtNormal()
+{
+ var msc = getOpenedDatabase();
+ var stmt = createStatement("PRAGMA synchronous;");
+ try {
+ stmt.executeStep();
+ do_check_eq(1, stmt.getInt32(0));
+ }
+ finally {
+ stmt.reset();
+ stmt.finalize();
+ }
+}
+
var tests = [
test_connectionReady_open,
test_connectionReady_closed,
@@ -216,6 +230,7 @@ var tests = [
test_set_schemaVersion_same,
test_set_schemaVersion_negative,
test_createTable,
+ test_defaultSynchronousAtNormal,
];
function run_test()

View file

@ -10,7 +10,7 @@
Summary: XUL Runtime for Gecko Applications
Name: xulrunner
Version: 1.9
Release: 0.61%{?version_pre}%{?dist}
Release: 0.62%{?version_pre}%{?dist}
URL: http://www.mozilla.org/projects/xulrunner/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Group: Applications/Internet
@ -34,6 +34,7 @@ Patch21: mozilla-wtfbuttons.patch
Patch22: mozilla-keys.patch
Patch23: xulrunner-hang.patch
Patch24: mozilla-resolution.patch
Patch25: mozilla-fsync.patch
# ---------------------------------------------------
@ -108,6 +109,7 @@ cd mozilla
%patch22 -p1 -b .keys
%patch23 -p1 -b .hang
%patch24 -p1 -b .resolution
%patch25 -p1 -b .fsync
%{__rm} -f .mozconfig
%{__cp} %{SOURCE10} .mozconfig
@ -380,6 +382,9 @@ fi
#---------------------------------------------------------------------
%changelog
* Thu May 22 2008 Christopher Aillon <caillon@redhat.com> 1.0-0.62
- Upstream patch to fsync() less
* Thu May 08 2008 Colin Walters <walters@redhat.com> 1.0-0.61
- Ensure we enable startup notification; add BR and modify config
(bug #445543)