Skip to content

Commit

Permalink
squash: fix listener test data race
Browse files Browse the repository at this point in the history
  • Loading branch information
ThinkChaos committed Aug 30, 2024
1 parent 8d9e373 commit c8eed23
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion service/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var _ = Describe("Service Listener", func() {

ch := make(chan struct{})
data := []byte("test")
addr := l.Addr().String() // read before starting the goroutine to avoid a race

// Server goroutine
go func() {
Expand All @@ -77,7 +78,7 @@ var _ = Describe("Service Listener", func() {

var conn net.Conn
By("connecting to server", func() {
conn, err = funcs.Dial(ctx, l.Addr().String())
conn, err = funcs.Dial(ctx, addr)
Expect(err).Should(Succeed())
DeferCleanup(conn.Close)
})
Expand Down

0 comments on commit c8eed23

Please sign in to comment.