mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix: properly set object with DenseLinkKey (#3980)
The interface around DenseLinkKey is confusing but SetObject works only for non-link objects. Added assert to catch these issues in the future. Fixes #3973 Signed-off-by: Roman Gershman <roman@dragonflydb.io>
This commit is contained in:
parent
132ffe0920
commit
a4659c0843
3 changed files with 28 additions and 3 deletions
|
@ -47,14 +47,16 @@ DenseSet::IteratorBase::IteratorBase(const DenseSet* owner, bool is_end)
|
|||
}
|
||||
|
||||
void DenseSet::IteratorBase::SetExpiryTime(uint32_t ttl_sec) {
|
||||
DensePtr* ptr = curr_entry_->IsLink() ? curr_entry_->AsLink() : curr_entry_;
|
||||
void* src = ptr->GetObject();
|
||||
if (!HasExpiry()) {
|
||||
auto src = curr_entry_->GetObject();
|
||||
void* new_obj = owner_->ObjectClone(src, false, true);
|
||||
curr_entry_->SetObject(new_obj);
|
||||
ptr->SetObject(new_obj);
|
||||
curr_entry_->SetTtl(true);
|
||||
owner_->ObjDelete(src, false);
|
||||
src = new_obj;
|
||||
}
|
||||
owner_->ObjUpdateExpireTime(curr_entry_->GetObject(), ttl_sec);
|
||||
owner_->ObjUpdateExpireTime(src, ttl_sec);
|
||||
}
|
||||
|
||||
void DenseSet::IteratorBase::Advance() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue