Fix race condition

This commit is contained in:
Tyler Treat
2017-06-19 15:14:31 -05:00
parent f98e327b74
commit 06d9aa7739
2 changed files with 8 additions and 1 deletions

View File

@@ -1325,6 +1325,11 @@ func (c *client) closeConnection() {
retryImplicit = c.route.retry
}
closed := false
if c.route != nil {
closed = c.route.closed
}
c.mu.Unlock()
if srv != nil {
@@ -1343,7 +1348,7 @@ func (c *client) closeConnection() {
}
// Don't reconnect routes that are being closed.
if c.route != nil && c.route.closed {
if c.route != nil && closed {
return
}

View File

@@ -396,7 +396,9 @@ func (s *Server) reloadAuthorization() {
for _, client := range routes {
// Disconnect any unauthorized routes.
if !s.isRouterAuthorized(client) {
client.mu.Lock()
client.route.closed = true
client.mu.Unlock()
client.authViolation()
}
}