Add a comment to explain that we want to make a copy of the config

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2021-08-31 15:11:32 -06:00
parent 0c9952f21d
commit 80ebf2d7b2

View File

@@ -1262,6 +1262,8 @@ func (s *Server) HandleRoot(w http.ResponseWriter, r *http.Request) {
func (s *Server) updateJszVarz(js *jetStream, v *JetStreamVarz, doConfig bool) {
if doConfig {
js.mu.RLock()
// We want to snapshot the config since it will then be available outside
// of the js lock. So make a copy first, then point to this copy.
cfg := js.config
v.Config = &cfg
js.mu.RUnlock()