Skip to content

Commit

Permalink
fix flapping test
Browse files Browse the repository at this point in the history
  • Loading branch information
ameshkov committed Feb 5, 2024
1 parent c3177c1 commit aeb4ad6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/testutil/udpechoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *UDPEchoServer) ReceivedMsg(num int) (b []byte) {
s.mu.Lock()
defer s.mu.Unlock()

if len(s.received) < num {
if len(s.received) <= num {
return nil
}

Expand Down Expand Up @@ -96,10 +96,11 @@ func (s *UDPEchoServer) serveConn(conn net.Conn) {

msg := make([]byte, n)
copy(msg, buf[:n])
_, _ = conn.Write(msg)

s.mu.Lock()
s.received = append(s.received, msg)
s.mu.Unlock()

_, _ = conn.Write(msg)
}
}

0 comments on commit aeb4ad6

Please sign in to comment.