From e370916a6f55cd2f3fb08218a9245dd26e874605 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 25 Dec 2024 00:03:32 -0800 Subject: [PATCH] fw: fix pit test PIT entries once removed cannot be reused, even for removing. Since remove is only called from the priority queue expiration function, this should not be a problem. --- fw/table/pit-cs-tree.go | 1 + fw/table/pit-cs-tree_test.go | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fw/table/pit-cs-tree.go b/fw/table/pit-cs-tree.go index 6788f8a0..0cf69f13 100644 --- a/fw/table/pit-cs-tree.go +++ b/fw/table/pit-cs-tree.go @@ -198,6 +198,7 @@ func (p *PitCsTree) InsertInterest(interest ndn.Interest, hint enc.Name, inFace // RemoveInterest removes the specified PIT entry, returning true if the entry // was removed and false if was not (because it does not exist). +// The pitEntry should NEVER be used again after this call. func (p *PitCsTree) RemoveInterest(pitEntry PitEntry) bool { e := pitEntry.(*nameTreePitEntry) // No error check needed because PitCsTree always uses nameTreePitEntry for i, entry := range e.node.pitEntries { diff --git a/fw/table/pit-cs-tree_test.go b/fw/table/pit-cs-tree_test.go index 3e09e564..1879038d 100644 --- a/fw/table/pit-cs-tree_test.go +++ b/fw/table/pit-cs-tree_test.go @@ -262,14 +262,12 @@ func TestRemoveInterest(t *testing.T) { assert.True(t, removedInterest) assert.Equal(t, pitCS.PitSize(), 0) - // Remove a nonexistent pit entry + // Remove a new pit entry name2, _ := enc.NameFromStr("/interest2") interest2 := makeInterest(name2) pitEntry2, _ := pitCS.InsertInterest(interest2, hint, inFace) - - removedInterest = pitCS.RemoveInterest(pitEntry) - assert.False(t, removedInterest) assert.Equal(t, pitCS.PitSize(), 1) + removedInterest = pitCS.RemoveInterest(pitEntry2) assert.True(t, removedInterest) assert.Equal(t, pitCS.PitSize(), 0)