libnetwork/diagnostic: lock mutex in help handler
Acquire the mutex in the help handler to synchronize access to the handlers map. While a trivial issue---a panic in the request handler if the node joins a swarm at just the right time, which would only result in an HTTP 500 response---it is also a trivial race condition to fix. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
424ae36046
commit
1931a1bdc7
1 changed files with 2 additions and 0 deletions
|
@ -147,9 +147,11 @@ func (s *Server) help(w http.ResponseWriter, r *http.Request) {
|
|||
}).Info("help done")
|
||||
|
||||
var result string
|
||||
s.mu.Lock()
|
||||
for path := range s.handlers {
|
||||
result += fmt.Sprintf("%s\n", path)
|
||||
}
|
||||
s.mu.Unlock()
|
||||
_, _ = HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), jsonOutput)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue