From 6cd1c02156ac0e54fab2307f3db98c90863be2ac Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Wed, 22 Jun 2016 23:17:57 +0200 Subject: [PATCH] Fix data race on client close The queue state object needs to be locked when removing a subscriber from the list. --- server/server.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/server.go b/server/server.go index 9b5f40d1..0fb9a924 100644 --- a/server/server.go +++ b/server/server.go @@ -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) }