From e9e2bb6f2d98efb590a738445e62aacd146ed903 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 Jun 2017 20:07:28 -0700 Subject: [PATCH] dhcp4: avoid reusing `bs` between the writing and reading tests. Although it looks like the sequencing of writing bs to the socket and reusing the slice for the read test is guaranteed by there being a receive from the socket in between, the race detector disagrees, and found a race. --- dhcp4/conn_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dhcp4/conn_test.go b/dhcp4/conn_test.go index bd09d3c..f98fe22 100644 --- a/dhcp4/conn_test.go +++ b/dhcp4/conn_test.go @@ -70,13 +70,13 @@ func testConn(t *testing.T, impl conn, addr string) { // Test writing p.ClientAddr = net.IPv4(127, 0, 0, 1) dhcpClientPort = s.LocalAddr().(*net.UDPAddr).Port - bs, err = p.Marshal() + bs2, err := p.Marshal() if err != nil { t.Fatalf("marshaling packet: %s", err) } // Unmarshal the packet again, to smooth out representation // differences (e.g. nil IP vs. IP set to 0.0.0.0). - p, err = Unmarshal(bs) + p, err = Unmarshal(bs2) if err != nil { t.Fatal(err) }