From bb0e6429bd2db99230e62797240e5a18dc2b0344 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Thu, 6 Aug 2015 00:20:17 -0700 Subject: [PATCH] Fixed race condition --- server/client.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/client.go b/server/client.go index 97a9d3a708..078b9a9b74 100644 --- a/server/client.go +++ b/server/client.go @@ -778,16 +778,20 @@ func (c *client) processMsg(msg []byte) { if rmap == nil { rmap = make(map[string]struct{}, srv.numRoutes()) } - if sub.client == nil || sub.client.nc == nil || sub.client.route == nil || + sub.client.mu.Lock() + if sub.client.nc == nil || sub.client.route == nil || sub.client.route.remoteID == "" { c.Debugf("Bad or Missing ROUTER Identity, not processing msg") + sub.client.mu.Unlock() continue } if _, ok := rmap[sub.client.route.remoteID]; ok { c.Debugf("Ignoring route, already processed") + sub.client.mu.Unlock() continue } rmap[sub.client.route.remoteID] = routeSeen + sub.client.mu.Unlock() } mh := c.msgHeader(msgh[:si], sub)