Fixed race condition

This commit is contained in:
Derek Collison
2015-08-06 00:20:17 -07:00
parent 0a0f322231
commit bb0e6429bd

View File

@@ -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)