Fix a concurrent write/read on the server conn map

This commit is contained in:
Mike Poindexter 2020-03-20 16:47:13 -07:00
parent 0490734b74
commit 84cabd77f9
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
} }
} }