Browse Source

test: fix test data race in p2p.MemoryTransport with logger (#5995)

This patches over a test data race where the logger would try to read struct internals via `reflect` while these were concurrently modified (specifically `MemoryTransport.closeOnce`).
pull/5995/merge
Erik Grinaker 3 years ago
committed by GitHub
parent
commit
aead4ab555
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      p2p/transport_memory.go

+ 10
- 0
p2p/transport_memory.go View File

@ -135,6 +135,16 @@ func newMemoryTransport(
}
}
// String displays the transport.
//
// FIXME: The Transport interface should either have Name() or embed
// fmt.Stringer. This is necessary since we log the transport (to know which one
// it is), and if it doesn't implement fmt.Stringer then it inspects all struct
// contents via reflect, which triggers the race detector.
func (t *MemoryTransport) String() string {
return "memory"
}
// Accept implements Transport.
func (t *MemoryTransport) Accept(ctx context.Context) (Connection, error) {
select {


Loading…
Cancel
Save