From 22507aff6c852b73e2d98ede5367984b79e63516 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Wed, 19 Mar 2014 15:40:12 -0700 Subject: [PATCH] Fix compile issue in Mac OS Summary: Compile issues are: * Unused variable env_ * Unused fallocate_with_keep_size_ Test Plan: compiles Reviewers: dhruba, haobo, sdong Reviewed By: dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D17043 --- db/db_test.cc | 8 +++----- util/env_posix.cc | 24 ++++++++++++++++++------ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 5c076ce5b..d126bb530 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -2057,8 +2057,7 @@ TEST(DBTest, NumImmutableMemTable) { class SleepingBackgroundTask { public: - explicit SleepingBackgroundTask(Env* env) - : env_(env), bg_cv_(&mutex_), should_sleep_(true) {} + SleepingBackgroundTask() : bg_cv_(&mutex_), should_sleep_(true) {} void DoSleep() { MutexLock l(&mutex_); while (should_sleep_) { @@ -2076,7 +2075,6 @@ class SleepingBackgroundTask { } private: - const Env* env_; port::Mutex mutex_; port::CondVar bg_cv_; // Signalled when background work finishes bool should_sleep_; @@ -2086,10 +2084,10 @@ TEST(DBTest, GetProperty) { // Set sizes to both background thread pool to be 1 and block them. env_->SetBackgroundThreads(1, Env::HIGH); env_->SetBackgroundThreads(1, Env::LOW); - SleepingBackgroundTask sleeping_task_low(env_); + SleepingBackgroundTask sleeping_task_low; env_->Schedule(&SleepingBackgroundTask::DoSleepTask, &sleeping_task_low, Env::Priority::LOW); - SleepingBackgroundTask sleeping_task_high(env_); + SleepingBackgroundTask sleeping_task_high; env_->Schedule(&SleepingBackgroundTask::DoSleepTask, &sleeping_task_high, Env::Priority::HIGH); diff --git a/util/env_posix.cc b/util/env_posix.cc index c610c1546..856d49250 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -356,7 +356,9 @@ class PosixMmapFile : public WritableFile { uint64_t file_offset_; // Offset of base_ in file // Have we done an munmap of unsynced data? bool pending_sync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif // Roundup x to a multiple of y static size_t Roundup(size_t x, size_t y) { @@ -441,8 +443,10 @@ class PosixMmapFile : public WritableFile { dst_(nullptr), last_sync_(nullptr), file_offset_(0), - pending_sync_(false), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + pending_sync_(false) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert((page_size & (page_size - 1)) == 0); assert(options.use_mmap_writes); } @@ -614,7 +618,9 @@ class PosixWritableFile : public WritableFile { bool pending_fsync_; uint64_t last_sync_size_; uint64_t bytes_per_sync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif public: PosixWritableFile(const std::string& fname, int fd, size_t capacity, @@ -628,8 +634,10 @@ class PosixWritableFile : public WritableFile { pending_sync_(false), pending_fsync_(false), last_sync_size_(0), - bytes_per_sync_(options.bytes_per_sync), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + bytes_per_sync_(options.bytes_per_sync) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert(!options.use_mmap_writes); } @@ -809,15 +817,19 @@ class PosixRandomRWFile : public RandomRWFile { int fd_; bool pending_sync_; bool pending_fsync_; +#ifdef ROCKSDB_FALLOCATE_PRESENT bool fallocate_with_keep_size_; +#endif public: PosixRandomRWFile(const std::string& fname, int fd, const EnvOptions& options) : filename_(fname), fd_(fd), pending_sync_(false), - pending_fsync_(false), - fallocate_with_keep_size_(options.fallocate_with_keep_size) { + pending_fsync_(false) { +#ifdef ROCKSDB_FALLOCATE_PRESENT + fallocate_with_keep_size_ = options.fallocate_with_keep_size; +#endif assert(!options.use_mmap_writes && !options.use_mmap_reads); }