diff --git a/mockserver_test.go b/mockserver_test.go
index <HASH>..<HASH> 100644
--- a/mockserver_test.go
+++ b/mockserver_test.go
@@ -115,7 +115,6 @@ func (s *server) serve() {
 			return
 		}
 		s.wg.Add(1)
-		s.conns[conn] = struct{}{}
 		go s.handle(conn)
 	}
 }
@@ -154,6 +153,9 @@ func (s *server) running() bool {
 
 // handle handles a client connection.
 func (s *server) handle(conn net.Conn) {
+	s.mtx.Lock()
+	s.conns[conn] = struct{}{}
+	s.mtx.Unlock()
 	defer func() {
 		s.closeConn(conn)
 		s.wg.Done()
Fixed data race in mock server

Fixed a data race in mock server on conns map.