bugfix-node-not-leaving

- Add lock when perform synchronisation on concurrent access
This commit is contained in:
Tim Beatham
2024-01-04 00:23:20 +00:00
parent 27e00196cd
commit 1f0914e2df
3 changed files with 7 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ type SyncerImpl struct {
cluster conn.ConnCluster
conf *conf.DaemonConfiguration
lastSync map[string]int64
lock sync.RWMutex
}
// Sync: Sync with random nodes
@@ -134,7 +135,9 @@ func (s *SyncerImpl) Sync(correspondingMesh mesh.MeshProvider) error {
correspondingMesh.SaveChanges()
s.lock.Lock()
s.lastSync[correspondingMesh.GetMeshId()] = time.Now().Unix()
s.lock.Unlock()
return nil
}