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 d1acc36
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions service/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ var _ = Describe("Service Listener", func() {
go func() {
defer GinkgoRecover()

var c net.Conn
var (
conn net.Conn
err error // separate var to avoid data-race
)
By("accepting client connection", func() {
c, err = l.Accept()
conn, err = l.Accept()
Expect(err).Should(Succeed())
DeferCleanup(c.Close)
DeferCleanup(conn.Close)
})

By("sending data to the client", func() {
Expect(c.Write(data)).Should(Equal(len(data)))
Expect(conn.Write(data)).Should(Equal(len(data)))
})

close(ch)
Expand Down

0 comments on commit d1acc36

Please sign in to comment.