Merge branch 'mpoindexter-fix-race-in-replconf'

This commit is contained in:
tidwall 2020-03-21 17:30:41 -07:00
commit 81e449afef
1 changed files with 4 additions and 0 deletions

View File

@ -121,9 +121,13 @@ func (s *Server) cmdReplConf(msg *Message, client *Client) (res resp.Value, err
} }
// Apply the replication port to the client and return // Apply the replication port to the client and return
s.connsmu.RLock()
defer s.connsmu.RUnlock()
for _, c := range s.conns { for _, c := range s.conns {
if c.remoteAddr == client.remoteAddr { if c.remoteAddr == client.remoteAddr {
c.mu.Lock()
c.replPort = port c.replPort = port
c.mu.Unlock()
return OKMessage(msg, start), nil return OKMessage(msg, start), nil
} }
} }