Merge pull request #486 from saltatory/master

Added RLock on connections map
This commit is contained in:
Josh Baker 2019-08-09 09:45:52 -07:00 committed by GitHub
commit 047d2dcbff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
} }