Skip to content

Commit

Permalink
pit: fix lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Dec 17, 2024
1 parent ebc5369 commit 895d1e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions table/pit-cs-tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ func (p *PitCsTree) IsCsServing() bool {
// InsertOutRecord inserts an outrecord for the given interest, updating the
// preexisting one if it already occcurs.
func (e *nameTreePitEntry) InsertOutRecord(interest *spec.Interest, face uint64) *PitOutRecord {
lifetime := time.Millisecond * 4000
if interest.Lifetime() != nil {
lifetime = *interest.Lifetime()
}

var record *PitOutRecord
var ok bool
if record, ok = e.outRecords[face]; !ok {
Expand All @@ -275,7 +280,7 @@ func (e *nameTreePitEntry) InsertOutRecord(interest *spec.Interest, face uint64)
record.LatestNonce = *interest.NonceV
record.LatestTimestamp = time.Now()
record.LatestInterest = interest.NameV.Clone()
record.ExpirationTime = time.Now().Add(time.Millisecond * 4000)
record.ExpirationTime = time.Now().Add(lifetime)
e.outRecords[face] = record
return record
}
Expand All @@ -284,7 +289,7 @@ func (e *nameTreePitEntry) InsertOutRecord(interest *spec.Interest, face uint64)
record.LatestNonce = *interest.NonceV
record.LatestTimestamp = time.Now()
record.LatestInterest = interest.NameV.Clone()
record.ExpirationTime = time.Now().Add(time.Millisecond * 4000)
record.ExpirationTime = time.Now().Add(lifetime)
return record
}

Expand Down
9 changes: 7 additions & 2 deletions table/pit-cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ func (bpe *basePitEntry) InsertInRecord(
face uint64,
incomingPitToken []byte,
) (*PitInRecord, bool) {
lifetime := time.Millisecond * 4000
if interest.Lifetime() != nil {
lifetime = *interest.Lifetime()
}

var record *PitInRecord
var ok bool
if record, ok = bpe.inRecords[face]; !ok {
Expand All @@ -132,7 +137,7 @@ func (bpe *basePitEntry) InsertInRecord(
record.LatestNonce = *interest.NonceV
record.LatestTimestamp = time.Now()
record.LatestInterest = interest.NameV.Clone()
record.ExpirationTime = time.Now().Add(time.Millisecond * 4000)
record.ExpirationTime = time.Now().Add(lifetime)
record.PitToken = append([]byte{}, incomingPitToken...)
bpe.inRecords[face] = record
return record, false
Expand All @@ -142,7 +147,7 @@ func (bpe *basePitEntry) InsertInRecord(
record.LatestNonce = *interest.NonceV
record.LatestTimestamp = time.Now()
record.LatestInterest = interest.NameV.Clone()
record.ExpirationTime = time.Now().Add(time.Millisecond * 4000)
record.ExpirationTime = time.Now().Add(lifetime)
return record, true
}

Expand Down

0 comments on commit 895d1e2

Please sign in to comment.