Skip to content

Commit

Permalink
Don't keep TaskScheduler busy when DBPartition is disabled
Browse files Browse the repository at this point in the history
Change-Id: I8bf3caee87dc5914bebedcfd6569ee730acfea24
Partial-Bug: 1548570
  • Loading branch information
Nischal Sheth committed Mar 3, 2016
1 parent aebe2a2 commit 52e294b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/db/db_partition.cc
Expand Up @@ -148,7 +148,12 @@ bool DBPartition::IsDBQueueEmpty() const {
}

void DBPartition::SetQueueDisable(bool disable) {
work_queue_->set_disable(disable);
if (disable) {
work_queue_->set_disable(true);
} else {
work_queue_->set_disable(false);
work_queue_->MaybeStartRunner();
}
}

class DBPartition::QueueRunner : public Task {
Expand All @@ -162,10 +167,9 @@ class DBPartition::QueueRunner : public Task {
virtual bool Run() {
int count = 0;

//
// Skip if the queue is disabled from running
//
if (queue_->disable()) return false;
// Skip if the queue is disabled.
if (queue_->disable())
return queue_->RunnerDone();

RemoveQueueEntry *rm_entry = NULL;
while (queue_->DequeueRemove(&rm_entry)) {
Expand Down Expand Up @@ -228,7 +232,7 @@ void DBPartition::WorkQueue::MaybeStartRunner() {

bool DBPartition::WorkQueue::RunnerDone() {
tbb::mutex::scoped_lock lock(mutex_);
if (request_queue_.empty() && remove_queue_.empty()) {
if (disable_ || (request_queue_.empty() && remove_queue_.empty())) {
running_ = false;
return true;
}
Expand Down

0 comments on commit 52e294b

Please sign in to comment.