Don't delete all the non-tombstone entries every 10mins!

This commit is contained in:
Tom Wilkie committed 2015-07-20 12:03:46 +00:00
1 parent 9ab2da8deb
commit 1a4b38a10c
3 files changed
+5 -1

No files matched your search

+1
View File
@@ -131,6 +131,7 @@ func (es *Entries) merge(incoming Entries) Entries {
return newEntries
}
// f returning true means keep the entry.
func (es *Entries) tombstone(ourname router.PeerName, f func(*Entry) bool) Entries {
es.checkAndPanic()
defer es.checkAndPanic()
+1 -1
View File
@@ -176,7 +176,7 @@ func (n *Nameserver) deleteTombstones() {
defer n.Unlock()
now := time.Now().Unix()
n.entries.filter(func(e *Entry) bool {
return now-e.Tombstone <= int64(tombstoneTimeout/time.Second)
return e.Tombstone == 0 || now-e.Tombstone <= int64(tombstoneTimeout/time.Second)
})
}
+3
View File
@@ -230,6 +230,9 @@ func TestTombstoneDeletion(t *testing.T) {
require.Nil(t, err)
require.Equal(t, []address.Address{0}, nameserver.Lookup("hostname"))
nameserver.deleteTombstones()
require.Equal(t, []address.Address{0}, nameserver.Lookup("hostname"))
err = nameserver.Delete("hostname", "containerid", "", address.Address(0))
require.Nil(t, err)
require.Equal(t, []address.Address{}, nameserver.Lookup("hostname"))