mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-21 06:36:19 +00:00
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`).
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user