mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-05 00:44:10 -04:00
Remove redundant lock in peer update logic to avoid deadlock with exported functions (#4953)
This commit is contained in:
@@ -20,7 +20,7 @@ type EndpointUpdater struct {
|
|||||||
wgConfig WgConfig
|
wgConfig WgConfig
|
||||||
initiator bool
|
initiator bool
|
||||||
|
|
||||||
// mu protects updateWireGuardPeer and cancelFunc
|
// mu protects cancelFunc
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
cancelFunc func()
|
cancelFunc func()
|
||||||
updateWg sync.WaitGroup
|
updateWg sync.WaitGroup
|
||||||
@@ -86,11 +86,9 @@ func (e *EndpointUpdater) scheduleDelayedUpdate(ctx context.Context, addr *net.U
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
e.mu.Lock()
|
|
||||||
if err := e.updateWireGuardPeer(addr, presharedKey); err != nil {
|
if err := e.updateWireGuardPeer(addr, presharedKey); err != nil {
|
||||||
e.log.Errorf("failed to update WireGuard peer, address: %s, error: %v", addr, err)
|
e.log.Errorf("failed to update WireGuard peer, address: %s, error: %v", addr, err)
|
||||||
}
|
}
|
||||||
e.mu.Unlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user