mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 03:24:40 -07:00
Fix race condition
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user