Skip to content

Commit

Permalink
Change RLock to a Lock in shouldKeep in sample node
Browse files Browse the repository at this point in the history
  • Loading branch information
desa committed Mar 2, 2017
1 parent f97f8e4 commit 32d1502
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,10 @@ func (s *SampleNode) shouldKeep(group models.GroupID, t time.Time) bool {
keepTime := t.Truncate(s.duration)
return t.Equal(keepTime)
} else {
s.countsMu.RLock()
s.countsMu.Lock()
count := s.counts[group]
s.countsMu.RUnlock()
keep := count%s.s.N == 0
count++
s.countsMu.Lock()
s.counts[group] = count
s.countsMu.Unlock()
return keep
Expand Down

0 comments on commit 32d1502

Please sign in to comment.