From 84cabd77f9ed09858fc8b0470ef0c24f99506e97 Mon Sep 17 00:00:00 2001 From: Mike Poindexter Date: Fri, 20 Mar 2020 16:47:13 -0700 Subject: [PATCH] Fix a concurrent write/read on the server conn map --- internal/server/follow.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/server/follow.go b/internal/server/follow.go index 856e532a..0ac1df12 100644 --- a/internal/server/follow.go +++ b/internal/server/follow.go @@ -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 + s.connsmu.RLock() + defer s.connsmu.RUnlock() for _, c := range s.conns { if c.remoteAddr == client.remoteAddr { + c.mu.Lock() c.replPort = port + c.mu.Unlock() return OKMessage(msg, start), nil } }