Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
localstore: fix data races on subscriptions (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
acud authored Nov 21, 2019
1 parent 91007c6 commit 47b8a33
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions storage/localstore/subscription_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ func (db *DB) LastPullSubscriptionBinID(bin uint8) (id uint64, err error) {
// this function should be called.
func (db *DB) triggerPullSubscriptions(bin uint8) {
db.pullTriggersMu.RLock()
defer db.pullTriggersMu.RUnlock()

triggers, ok := db.pullTriggers[bin]
db.pullTriggersMu.RUnlock()
if !ok {
return
}

for _, t := range triggers {
select {
case t <- struct{}{}:
Expand Down
5 changes: 2 additions & 3 deletions storage/localstore/subscription_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,9 @@ func (db *DB) SubscribePush(ctx context.Context) (c <-chan chunk.Chunk, stop fun
// this function should be called.
func (db *DB) triggerPushSubscriptions() {
db.pushTriggersMu.RLock()
triggers := db.pushTriggers
db.pushTriggersMu.RUnlock()
defer db.pushTriggersMu.RUnlock()

for _, t := range triggers {
for _, t := range db.pushTriggers {
select {
case t <- struct{}{}:
default:
Expand Down

0 comments on commit 47b8a33

Please sign in to comment.