Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid adding empty deltas to the cache #117

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,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) == false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (s.server.AddData(SDs) == false) {
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()
Expand Down
9 changes: 7 additions & 2 deletions lib/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -373,7 +373,12 @@ func (s *Server) AddData(new []SendableData) {
curDiff := append(added, removed...)
s.sdlock.RUnlock()

s.AddSDsDiff(curDiff)
if (len(curDiff) == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (len(curDiff) == 0) {
if len(curDiff) == 0 {

I think gofmt would have applied this automatically

return false
} else {
s.AddSDsDiff(curDiff)
return true
}
}

func (s *Server) addSerial(serial uint32) []uint32 {
Expand Down
Loading