hitting an account limit left an outgoing leaf node conn in bad state (#2715)

since no error was traced or the connection closed, subscriptions where
not forwarded

Signed-off-by: Matthias Hanel <mh@synadia.com>
This commit is contained in:
Matthias Hanel
2021-11-30 17:48:07 -05:00
committed by GitHub
parent 4f37cbdd8a
commit 581dfb27d0

View File

@@ -2527,7 +2527,15 @@ func (s *Server) leafNodeFinishConnectProcess(c *client) {
c.mu.Unlock()
// Make sure we register with the account here.
c.registerWithAccount(acc)
if err := c.registerWithAccount(acc); err != nil {
if err == ErrTooManyAccountConnections {
c.maxAccountConnExceeded()
return
}
c.Errorf("Registering leaf with account %s resulted in error: %v", acc.Name, err)
c.closeConnection(ProtocolViolation)
return
}
s.addLeafNodeConnection(c, _EMPTY_, _EMPTY_, false)
s.initLeafNodeSmapAndSendSubs(c)
if sendSysConnectEvent {