add comment in SuperVersion referencing logic

Summary:
The referencing logic is super confusing so added a comment at the part that took me longest to figure out.
Closes https://github.com/facebook/rocksdb/pull/2996

Differential Revision: D6034969

Pulled By: ajkr

fbshipit-source-id: 9cc2e744c1f79d6d57d378f86ed59238a5f583db
This commit is contained in:
Andrew Kryczka 2017-10-11 15:11:08 -07:00 committed by Facebook Github Bot
parent fb4ae4d810
commit 8dd0a7e11a
1 changed files with 4 additions and 0 deletions

View File

@ -854,6 +854,10 @@ SuperVersion* ColumnFamilyData::GetReferencedSuperVersion(
sv = GetThreadLocalSuperVersion(db_mutex);
sv->Ref();
if (!ReturnThreadLocalSuperVersion(sv)) {
// This Unref() corresponds to the Ref() in GetThreadLocalSuperVersion()
// when the thread-local pointer was populated. So, the Ref() earlier in
// this function still prevents the returned SuperVersion* from being
// deleted out from under the caller.
sv->Unref();
}
return sv;