From cb9802168f2c84a24af87b0dc08e0a4f9710c55d Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Tue, 11 Mar 2014 11:27:19 -0700 Subject: [PATCH] Add a comment after SignalAll() Summary: Having code after SignalAll has already caused 2 bugs. Let's make sure this doesn't happen again. Test Plan: no test Reviewers: sdong, dhruba, haobo Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D16785 --- db/db_impl.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index 65e8e437c..ca91b5e82 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1924,6 +1924,10 @@ void DBImpl::BackgroundCallFlush() { MaybeScheduleFlushOrCompaction(); } bg_cv_.SignalAll(); + // IMPORTANT: there should be no code after calling SignalAll. This call may + // signal the DB destructor that it's OK to proceed with destruction. In + // that case, all DB variables will be dealloacated and referencing them + // will cause trouble. } log_buffer.FlushBufferToLog(); } @@ -1993,6 +1997,10 @@ void DBImpl::BackgroundCallCompaction() { MaybeScheduleFlushOrCompaction(); } bg_cv_.SignalAll(); + // IMPORTANT: there should be no code after calling SignalAll. This call may + // signal the DB destructor that it's OK to proceed with destruction. In + // that case, all DB variables will be dealloacated and referencing them + // will cause trouble. } log_buffer.FlushBufferToLog(); }