@@ -348,24 +348,28 @@ Status TransBuffer::Setup(const Config& config)
348348TransBuffer::Handle TransBuffer::Get (const Detail::BlockId& blockId, size_t shardIdx)
349349{
350350 auto iBucket = Hash (blockId, shardIdx);
351+ bool owner = false ;
351352 strategy_->BucketLock (iBucket);
352- auto iNode = FindAt (iBucket, blockId, shardIdx);
353- strategy_->BucketUnlock (iBucket);
354- if (iNode != invalidIndex) { return Handle{this , iNode, false }; }
353+ auto iNode = FindAt (iBucket, blockId, shardIdx, owner);
354+ if (iNode != invalidIndex) {
355+ strategy_->BucketUnlock (iBucket);
356+ return Handle{this , iNode, owner};
357+ }
355358 iNode = Alloc (blockId, shardIdx);
356- strategy_->BucketLock (iBucket);
357359 MoveTo (iBucket, iNode);
358360 strategy_->BucketUnlock (iBucket);
359361 return Handle (this , iNode, true );
360362}
361363
362- size_t TransBuffer::FindAt (size_t iBucket, const Detail::BlockId& blockId, size_t shardIdx)
364+ size_t TransBuffer::FindAt (size_t iBucket, const Detail::BlockId& blockId, size_t shardIdx,
365+ bool & owner)
363366{
364367 auto iNode = strategy_->FirstAt (iBucket);
365368 while (iNode != invalidIndex) {
366369 auto meta = strategy_->MetaAt (iNode);
367370 strategy_->NodeLock (iNode);
368371 if (meta->block == blockId && meta->shard == shardIdx) {
372+ owner = meta->reference == 0 ;
369373 ++meta->reference ;
370374 strategy_->NodeUnlock (iNode);
371375 break ;
0 commit comments