提交 be410ded 编写于 作者: Y Yi Wu 提交者: Facebook Github Bot

Fix PinnableSlice move assignment

Summary:
After move assignment, we need to re-initialized the moved PinnableSlice.

Also update blob_db_impl.cc to not reuse the moved PinnableSlice since it is supposed to be in an undefined state after move.
Closes https://github.com/facebook/rocksdb/pull/3127

Differential Revision: D6238585

Pulled By: yiwu-arbug

fbshipit-source-id: bd99f2e37406c4f7de160c7dee6a2e8126bc224e
上级 a6d8e30c
......@@ -150,6 +150,10 @@ class PinnableSlice : public Slice, public Cleanable {
} else {
buf_ = other.buf_;
}
// Re-initialize the other PinnablaeSlice.
other.self_space_.clear();
other.buf_ = &other.self_space_;
other.pinned_ = false;
}
return *this;
}
......
......@@ -47,6 +47,7 @@ TEST_F(SliceTest, PinnableSliceMoveConstruct) {
ASSERT_EQ("bar", s2->ToString());
s2->RegisterCleanup(BumpCounter, &orig_cleanup, nullptr);
*s2 = std::move(*s1);
ASSERT_FALSE(s1->IsPinned());
ASSERT_EQ("foo", s2->ToString());
ASSERT_EQ(1, orig_cleanup);
ASSERT_EQ(0, moved_cleanup);
......
......@@ -1226,13 +1226,16 @@ Status BlobDBImpl::Get(const ReadOptions& read_options,
Status s;
bool is_blob_index = false;
s = db_impl_->GetImpl(ro, column_family, key, value, nullptr /*value_found*/,
nullptr /*read_callback*/, &is_blob_index);
PinnableSlice index_entry;
s = db_impl_->GetImpl(ro, column_family, key, &index_entry,
nullptr /*value_found*/, nullptr /*read_callback*/,
&is_blob_index);
TEST_SYNC_POINT("BlobDBImpl::Get:AfterIndexEntryGet:1");
TEST_SYNC_POINT("BlobDBImpl::Get:AfterIndexEntryGet:2");
if (s.ok()) {
if (is_blob_index) {
PinnableSlice index_entry = std::move(*value);
if (!is_blob_index) {
*value = std::move(index_entry);
} else {
s = GetBlobValue(key, index_entry, value);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册