Skip to content

Commit 88f2078

Browse files
authored
Merge branch 'netbirdio:ui-refactor' into ui-refactor
2 parents ac06bd0 + 1108808 commit 88f2078

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

client/internal/engine.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,14 @@ func (e *Engine) handleSync(update *mgmProto.SyncResponse) error {
953953
return nil
954954
}
955955

956-
// Persist sync response under the dedicated lock (syncRespMux), not under syncMsgMux.
956+
// only apply new changes and ignore old ones
957+
if err := e.updateNetworkMap(nm); err != nil {
958+
return err
959+
}
960+
961+
// Persist sync response only after updateNetworkMap accepted and applied the update,
962+
// so GetLatestSyncResponse() never returns state the engine did not actually apply.
963+
// Done under the dedicated lock (syncRespMux), not under syncMsgMux.
957964
// A non-nil syncStore is what marks persistence as enabled. Hold the lock for
958965
// the whole Set so the store cannot be cleared (disabled / engine close)
959966
// mid-call and have this write resurrect a file that was just removed.
@@ -967,11 +974,6 @@ func (e *Engine) handleSync(update *mgmProto.SyncResponse) error {
967974
}
968975
e.syncRespMux.RUnlock()
969976

970-
// only apply new changes and ignore old ones
971-
if err := e.updateNetworkMap(nm); err != nil {
972-
return err
973-
}
974-
975977
e.statusRecorder.PublishEvent(cProto.SystemEvent_INFO, cProto.SystemEvent_SYSTEM, "Network map updated", "", nil)
976978

977979
return nil

0 commit comments

Comments
 (0)