1
0
mirror of https://github.com/bgp/stayrtr.git synced 2024-05-06 15:54:54 +00:00

Merge pull request #117 from cjeker/avoid_empty_deltas

Avoid adding empty deltas to the cache
This commit is contained in:
Ties de Kock
2024-03-01 09:36:03 +01:00
committed by GitHub
2 changed files with 12 additions and 4 deletions

View File

@ -454,10 +454,13 @@ func (s *state) applyUpdateFromNewState(vrps []rtr.VRP, brks []rtr.BgpsecKey, va
for _, v := range vaps {
SDs = append(SDs, v.Copy())
}
s.server.AddData(SDs)
if !s.server.AddData(SDs) {
log.Info("No difference to current cache")
return nil
}
serial, _ := s.server.GetCurrentSerial(sessid)
log.Infof("Updated added, new serial %v", serial)
log.Infof("Update added, new serial %v", serial)
if s.sendNotifs {
log.Debugf("Sending notifications to clients")
s.server.NotifyClientsLatest()

View File

@ -361,7 +361,7 @@ func (s *Server) CountSDs() int {
return len(s.sdCurrent)
}
func (s *Server) AddData(new []SendableData) {
func (s *Server) AddData(new []SendableData) bool {
s.sdlock.RLock()
added, removed, _ := ComputeDiff(new, s.sdCurrent, false)
@ -373,7 +373,12 @@ func (s *Server) AddData(new []SendableData) {
curDiff := append(added, removed...)
s.sdlock.RUnlock()
s.AddSDsDiff(curDiff)
if len(curDiff) == 0 {
return false
} else {
s.AddSDsDiff(curDiff)
return true
}
}
func (s *Server) addSerial(serial uint32) []uint32 {