mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-07 15:23:08 +00:00
Fix Memory Leak In New Timecache Implementations (#528)
* fix bug * add for last seen cache
This commit is contained in:
parent
829f9026a3
commit
340387ef3f
@ -26,8 +26,10 @@ func TestFirstSeenCacheExpire(t *testing.T) {
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
if tc.Has(fmt.Sprint(0)) {
|
||||
t.Fatal("should have dropped this from the cache already")
|
||||
for i := 0; i < 10; i++ {
|
||||
if tc.Has(fmt.Sprint(i)) {
|
||||
t.Fatalf("should have dropped this key: %s from the cache already", fmt.Sprint(i))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -25,8 +25,10 @@ func TestLastSeenCacheExpire(t *testing.T) {
|
||||
}
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
if tc.Has(fmt.Sprint(0)) {
|
||||
t.Fatal("should have dropped this from the cache already")
|
||||
for i := 0; i < 11; i++ {
|
||||
if tc.Has(fmt.Sprint(i)) {
|
||||
t.Fatalf("should have dropped this key: %s from the cache already", fmt.Sprint(i))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import (
|
||||
var backgroundSweepInterval = time.Minute
|
||||
|
||||
func background(ctx context.Context, lk sync.Locker, m map[string]time.Time) {
|
||||
ticker := time.NewTimer(backgroundSweepInterval)
|
||||
ticker := time.NewTicker(backgroundSweepInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user