mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-29 15:59:10 +01:00
Guard is done inside not from external. Stop called unconditionally
This commit is contained in:
@@ -417,14 +417,12 @@ func (c *ConnectClient) run(runCtx context.Context, config *profilemanager.Confi
|
|||||||
c.engine = nil
|
c.engine = nil
|
||||||
c.engineMutex.Unlock()
|
c.engineMutex.Unlock()
|
||||||
|
|
||||||
// todo: consider to remove this condition. Is not thread safe.
|
// Always tear the engine down once its context is cancelled. engine.Stop
|
||||||
// We should always call Stop(), but we need to verify that it is idempotent
|
// is nil-guarded per component, so calling it unconditionally is safe and
|
||||||
if engine.wgInterface != nil {
|
// avoids both the data race on engine.wgInterface and skipping teardown
|
||||||
log.Infof("ensuring %s is removed, Netbird engine context cancelled", engine.wgInterface.Name())
|
// when the interface was never brought up (e.g. a mid-start failure).
|
||||||
|
if err := engine.Stop(); err != nil {
|
||||||
if err := engine.Stop(); err != nil {
|
log.Errorf("Failed to stop engine: %v", err)
|
||||||
log.Errorf("Failed to stop engine: %v", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.statusRecorder.ClientTeardown()
|
c.statusRecorder.ClientTeardown()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user