From 7ce37c1ec34e33f7e2c4b87341f16885942c3e5c Mon Sep 17 00:00:00 2001 From: vichang Date: Thu, 28 Jan 2016 14:09:03 -0800 Subject: Add flag to disable mmap in all sql connection in work build Work Chrome runs in environment without a proper mmap support. Disable it for all work chrome. BUG=554269 Review URL: https://codereview.chromium.org/1637683003 Cr-Commit-Position: refs/heads/master@{#372179} --- sql/connection.cc | 10 +++++++++- sql/connection.h | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'sql') diff --git a/sql/connection.cc b/sql/connection.cc index 003005a..f08560c 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -43,6 +43,8 @@ namespace { // TODO(shess): Better story on this. http://crbug.com/56559 const int kBusyTimeoutSeconds = 1; +bool g_mmap_disabled_default = false; + class ScopedBusyTimeout { public: explicit ScopedBusyTimeout(sqlite3* db) @@ -254,6 +256,12 @@ bool Connection::ShouldIgnoreSqliteCompileError(int error) { basic_error == SQLITE_CORRUPT; } +// static +void Connection::set_mmap_disabled_by_default() { + g_mmap_disabled_default = true; +} + + void Connection::ReportDiagnosticInfo(int extended_error, Statement* stmt) { AssertIOAllowed(); @@ -339,7 +347,7 @@ Connection::Connection() needs_rollback_(false), in_memory_(false), poisoned_(false), - mmap_disabled_(false), + mmap_disabled_(g_mmap_disabled_default), mmap_enabled_(false), total_changes_at_last_release_(0), stats_histogram_(NULL), diff --git a/sql/connection.h b/sql/connection.h index b35e2fa..4606a1f 100644 --- a/sql/connection.h +++ b/sql/connection.h @@ -149,9 +149,12 @@ class SQL_EXPORT Connection { // other platforms. void set_restrict_to_user() { restrict_to_user_ = true; } - // Call to opt out of memory-mapped file I/O. + // Call to opt out of memory-mapped file I/O on per connection basis. void set_mmap_disabled() { mmap_disabled_ = true; } + // Call to opt out of memory-mapped file I/O on all connections. + static void set_mmap_disabled_by_default(); + // Set an error-handling callback. On errors, the error number (and // statement, if available) will be passed to the callback. // -- cgit v1.1