Remove redundant lock in peer update logic to avoid deadlock with exported functions (#4953)

This commit is contained in:
Zoltan Papp
2025-12-17 13:55:33 +01:00
committed by GitHub
parent a9c28ef723
commit 537151e0f3

View File

@@ -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()
} }
} }