Added RLock on connections map

This commit is contained in:
saltatory 2019-08-09 08:48:23 -07:00
parent 815d7bc43d
commit ec5a5342a2
1 changed files with 2 additions and 0 deletions

View File

@ -365,6 +365,7 @@ func (c *Server) writeInfoReplication(w *bytes.Buffer) {
} else { } else {
fmt.Fprintf(w, "role:master\r\n") fmt.Fprintf(w, "role:master\r\n")
var i int var i int
c.connsmu.RLock()
for _, cc := range c.conns { for _, cc := range c.conns {
if cc.replPort != 0 { if cc.replPort != 0 {
fmt.Fprintf(w, "slave%v:ip=%s,port=%v,state=online\r\n", i, fmt.Fprintf(w, "slave%v:ip=%s,port=%v,state=online\r\n", i,
@ -372,6 +373,7 @@ func (c *Server) writeInfoReplication(w *bytes.Buffer) {
i++ i++
} }
} }
c.connsmu.RUnlock()
} }
fmt.Fprintf(w, "connected_slaves:%d\r\n", len(c.aofconnM)) // Number of connected slaves fmt.Fprintf(w, "connected_slaves:%d\r\n", len(c.aofconnM)) // Number of connected slaves
} }