Merge pull request #2348 from nats-io/sys-hdr

[fixed] CONNS system endpoint which had issues with header and empty msg
This commit is contained in:
Ivan Kozlovic
2021-07-06 14:49:00 -06:00
committed by GitHub

View File

@@ -1043,7 +1043,7 @@ func (s *Server) shutdownEventing() {
}
// Request for our local connection count.
func (s *Server) connsRequest(sub *subscription, _ *client, subject, reply string, msg []byte) {
func (s *Server) connsRequest(sub *subscription, c *client, subject, reply string, rmsg []byte) {
if !s.eventsRunning() {
return
}
@@ -1054,9 +1054,11 @@ func (s *Server) connsRequest(sub *subscription, _ *client, subject, reply strin
}
a := tk[accReqAccIndex]
m := accNumConnsReq{Account: a}
if err := json.Unmarshal(msg, &m); err != nil {
s.sys.client.Errorf("Error unmarshalling account connections request message: %v", err)
return
if _, msg := c.msgParts(rmsg); len(msg) > 0 {
if err := json.Unmarshal(msg, &m); err != nil {
s.sys.client.Errorf("Error unmarshalling account connections request message: %v", err)
return
}
}
if m.Account != a {
s.sys.client.Errorf("Error unmarshalled account does not match subject")