Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1296)

Unified Diff: sql/connection.cc

Issue 1414563010: [sql] Disable memory-mapping under sql::Recovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sql/recovery.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index a904632eb517e066596855ab980fe3ce8a80aff3..79264916c0274c3cda466ccee94750b35e3f798d 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -1628,18 +1628,6 @@ bool Connection::OpenInternal(const std::string& file_name,
// secure_delete.
ignore_result(Execute("PRAGMA journal_mode = TRUNCATE"));
- // Enable memory-mapped access. This value will be capped by
- // SQLITE_MAX_MMAP_SIZE, which could be different between 32-bit and 64-bit
- // platforms.
- mmap_enabled_ = false;
- if (!mmap_disabled_)
- ignore_result(Execute("PRAGMA mmap_size = 268435456")); // 256MB.
- {
- Statement s(GetUniqueStatement("PRAGMA mmap_size"));
- if (s.Step() && s.ColumnInt64(0) > 0)
- mmap_enabled_ = true;
- }
-
const base::TimeDelta kBusyTimeout =
base::TimeDelta::FromSeconds(kBusyTimeoutSeconds);
@@ -1668,6 +1656,25 @@ bool Connection::OpenInternal(const std::string& file_name,
return false;
}
+ // Enable memory-mapped access. The explicit-disable case is because SQLite
+ // can be built to default-enable mmap. This value will be capped by
+ // SQLITE_MAX_MMAP_SIZE, which could be different between 32-bit and 64-bit
+ // platforms.
+ if (mmap_disabled_) {
+ ignore_result(Execute("PRAGMA mmap_size = 0"));
+ } else {
+ ignore_result(Execute("PRAGMA mmap_size = 268435456")); // 256MB.
+ }
+
+ // Determine if memory-mapping has actually been enabled. The Execute() above
+ // can succeed without changing the amount mapped.
+ mmap_enabled_ = false;
+ {
+ Statement s(GetUniqueStatement("PRAGMA mmap_size"));
+ if (s.Step() && s.ColumnInt64(0) > 0)
+ mmap_enabled_ = true;
+ }
+
Scott Hess - ex-Googler 2015/11/04 23:36:42 Hmm, and I moved the stanza down here because it s
return true;
}
« no previous file with comments | « no previous file | sql/recovery.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698