Squashed 'src/leveldb/' changes from be1b0ff..936b461

936b461 Merge upstream LevelDB 1.13.
748539c LevelDB 1.13

git-subtree-dir: src/leveldb
git-subtree-split: 936b4613ea4551992e6096b1e05eeefc09a20e3b
This commit is contained in:
Pieter Wuille
2013-08-24 22:21:41 +02:00
parent 1bb86d6f15
commit eed29f0f50
13 changed files with 363 additions and 67 deletions

View File

@@ -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