mirror of
https://github.com/danderson/netboot.git
synced 2025-12-07 18:41:41 +01:00
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.
This commit is contained in:
parent
565eb761d1
commit
e9e2bb6f2d
@ -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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user