aboutsummaryrefslogtreecommitdiff
path: root/src/leveldb/util/env_posix.cc
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-08-24 22:21:41 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2013-08-24 22:21:41 +0200
commit877b5e3653f12882e12c75aa0bb5be47f847bd09 (patch)
tree399b43ec4298fdefe16fd9c33e684b3e58867755 /src/leveldb/util/env_posix.cc
parente9e2ef5fbd610fbaa3801440254c39ac4ba8f91d (diff)
parenteed29f0f50806b9cfe9653509e7ed7f7eebdd3e3 (diff)
Merge src/leveldb changes for LevelDB 1.13
Diffstat (limited to 'src/leveldb/util/env_posix.cc')
-rw-r--r--src/leveldb/util/env_posix.cc33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/leveldb/util/env_posix.cc b/src/leveldb/util/env_posix.cc
index 6badfdc230..0f5dcfac5a 100644
--- a/src/leveldb/util/env_posix.cc
+++ b/src/leveldb/util/env_posix.cc
@@ -320,8 +320,39 @@ class PosixMmapFile : public WritableFile {
return Status::OK();
}
- virtual Status Sync() {
+ Status SyncDirIfManifest() {
+ const char* f = filename_.c_str();
+ const char* sep = strrchr(f, '/');
+ Slice basename;
+ std::string dir;
+ if (sep == NULL) {
+ dir = ".";
+ basename = f;
+ } else {
+ dir = std::string(f, sep - f);
+ basename = sep + 1;
+ }
Status s;
+ if (basename.starts_with("MANIFEST")) {
+ int fd = open(dir.c_str(), O_RDONLY);
+ if (fd < 0) {
+ s = IOError(dir, errno);
+ } else {
+ if (fsync(fd) < 0) {
+ s = IOError(dir, errno);
+ }
+ close(fd);
+ }
+ }
+ return s;
+ }
+
+ virtual Status Sync() {
+ // Ensure new files referred to by the manifest are in the filesystem.
+ Status s = SyncDirIfManifest();
+ if (!s.ok()) {
+ return s;
+ }
if (pending_sync_) {
// Some unmapped data was not synced