[FIXED] Gateway: possible panic if monitor endpoint inspected too soon

The monitoring http server is started early and the gateway setup
(when configured) may not be fully ready when the `/gatewayz`
endpoint is inspected and could cause a panic.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2022-08-17 13:30:58 -06:00
parent c67d6aad79
commit 5d3ee8ebf4
3 changed files with 33 additions and 2 deletions

View File

@@ -1777,7 +1777,7 @@ func (s *Server) Gatewayz(opts *GatewayzOptions) (*Gatewayz, error) {
now := time.Now().UTC()
gw := s.gateway
gw.RLock()
if !gw.enabled {
if !gw.enabled || gw.info == nil {
gw.RUnlock()
gwz := &Gatewayz{
ID: srvID,