Skip to content

Commit 88b1a70

Browse files
authored
fix(relay): fix data-race in relayFinder (#3258)
`relayFinder.relays` should only be accessed with the `relayMx` held
1 parent 17fd610 commit 88b1a70

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

p2p/host/autorelay/relay_finder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ func (rf *relayFinder) updateAddrs() {
251251
// This function returns the p2p-circuit addrs for the host.
252252
// The returned addresses are of the form <relay's-addr>/p2p/<relay's-id>/p2p-circuit.
253253
func (rf *relayFinder) getCircuitAddrs() []ma.Multiaddr {
254+
rf.relayMx.Lock()
255+
defer rf.relayMx.Unlock()
256+
254257
raddrs := make([]ma.Multiaddr, 0, 4*len(rf.relays)+4)
255258
for p := range rf.relays {
256259
addrs := cleanupAddressSet(rf.host.Peerstore().Addrs(p))

0 commit comments

Comments
 (0)