diff --git a/sstables/compaction_manager.cc b/sstables/compaction_manager.cc index 044efc4f94..ae3b22931a 100644 --- a/sstables/compaction_manager.cc +++ b/sstables/compaction_manager.cc @@ -254,8 +254,12 @@ void compaction_manager::signal_less_busy_task() { (*result)->compaction_sem.signal(); } +bool compaction_manager::can_submit() { + return !_stopped && !_tasks.empty(); +} + void compaction_manager::submit(column_family* cf) { - if (_stopped || _tasks.empty()) { + if (!can_submit()) { return; } // To avoid having two or more entries of the same cf stored in the queue. @@ -268,7 +272,7 @@ void compaction_manager::submit(column_family* cf) { } void compaction_manager::submit_cleanup_job(column_family* cf) { - if (_stopped || _tasks.empty()) { + if (!can_submit()) { return; } // To avoid having two or more entries of the same cf stored in the queue. diff --git a/sstables/compaction_manager.hh b/sstables/compaction_manager.hh index 142a9b9086..ae895f304e 100644 --- a/sstables/compaction_manager.hh +++ b/sstables/compaction_manager.hh @@ -82,6 +82,10 @@ private: // This function is called when a cf is submitted for compaction and we need // to wake up a handler. void signal_less_busy_task(); + // Returns if this compaction manager is accepting new requests. + // It will not accept new requests in case the manager was stopped and/or there + // is no task to handle them. + bool can_submit(); public: compaction_manager(); ~compaction_manager();