mirror of
https://github.com/status-im/go-waku.git
synced 2025-02-26 20:10:44 +00:00
fix: data race in peer connector
This commit is contained in:
parent
20040f2e9b
commit
baeaa1dd55
@ -301,7 +301,9 @@ func (c *PeerConnectionStrategy) dialPeers(ctx context.Context) {
|
|||||||
c.wg.Add(1)
|
c.wg.Add(1)
|
||||||
go func(pi peer.AddrInfo) {
|
go func(pi peer.AddrInfo) {
|
||||||
defer c.wg.Done()
|
defer c.wg.Done()
|
||||||
|
c.RLock()
|
||||||
ctx, cancel := context.WithTimeout(c.workerCtx, c.dialTimeout)
|
ctx, cancel := context.WithTimeout(c.workerCtx, c.dialTimeout)
|
||||||
|
c.RUnlock()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
err := c.host.Connect(ctx, pi)
|
err := c.host.Connect(ctx, pi)
|
||||||
if err != nil && !errors.Is(err, context.Canceled) {
|
if err != nil && !errors.Is(err, context.Canceled) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user