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

Conversation

cjeker
Copy link
Contributor

@cjeker cjeker commented Feb 29, 2024

Return true or false from AddData().
Returns false and aborts the data addition if there is no change in the delta.
Use this to shortcut applyUpdateFromNewState() which prevents sending out notifications for empty deltas.

While detecting no file change for slurm using a hash (#115) prevents this case it still is an extra safety to prevent empty deltas to show up.

Returns false and aborts the data addition if there is no change in the delta.
Use this to shortcut applyUpdateFromNewState() which prevents sending out
notifications for empty deltas.
@@ -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) {

lib/server.go Outdated
@@ -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

@ties ties merged commit b93d7a8 into bgp:master Mar 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants