Skip to content

Commit

Permalink
finetune view waiting
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Jul 13, 2021
1 parent 257423e commit af39952
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,16 @@ type SplitStore struct {
debug *debugLog

// transactional protection for concurrent read/writes during compaction
txnLk sync.RWMutex
txnViewsMx sync.Mutex
txnViewsCond sync.Cond
txnViews int
txnActive bool
txnProtect MarkSet
txnRefsMx sync.Mutex
txnRefs map[cid.Cid]struct{}
txnMissing map[cid.Cid]struct{}
txnLk sync.RWMutex
txnViewsMx sync.Mutex
txnViewsCond sync.Cond
txnViews int
txnViewsWaiting bool
txnActive bool
txnProtect MarkSet
txnRefsMx sync.Mutex
txnRefs map[cid.Cid]struct{}
txnMissing map[cid.Cid]struct{}
}

var _ bstore.Blockstore = (*SplitStore)(nil)
Expand Down Expand Up @@ -651,7 +652,7 @@ func (s *SplitStore) viewDone() {
defer s.txnViewsMx.Unlock()

s.txnViews--
if s.txnViews == 0 {
if s.txnViews == 0 && s.txnViewsWaiting {
s.txnViewsCond.Signal()
}
}
Expand All @@ -660,9 +661,11 @@ func (s *SplitStore) viewWait() {
s.txnViewsMx.Lock()
defer s.txnViewsMx.Unlock()

s.txnViewsWaiting = true
for s.txnViews > 0 {
s.txnViewsCond.Wait()
}
s.txnViewsWaiting = false
}

// transactionally protect a reference to an object
Expand Down

0 comments on commit af39952

Please sign in to comment.