Skip to content

Commit

Permalink
Fix data race on client close
Browse files Browse the repository at this point in the history
The queue state object needs to be locked when removing a subscriber
from the list.
  • Loading branch information
kozlovic committed Jun 22, 2016
1 parent 7e894db commit 6cd1c02
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,12 @@ func (ss *subStore) Remove(sub *subState, force bool) {

// Delete ourselves from the list
if qs != nil {
// For queue state, we need to lock specifically,
// because qs.subs can be modified by findBestQueueSub,
// for which we don't have substore lock held.
qs.Lock()
qs.subs, _ = sub.deleteFromList(qs.subs)
qs.Unlock()
} else {
ss.psubs, _ = sub.deleteFromList(ss.psubs)
}
Expand Down

0 comments on commit 6cd1c02

Please sign in to comment.