Move map to array (#3339)
* Move map to array The map was not needed move to an array, see #1941 for the original idea. That of course didn't apply anymore; make a super minimal change to implements the idea from #1941 Signed-off-by: Miek Gieben <miek@miek.nl> * Add total count Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
parent
2d98d520b5
commit
575cea4496
3 changed files with 53 additions and 30 deletions
|
@ -96,18 +96,14 @@ func TestCleanupAll(t *testing.T) {
|
|||
c2, _ := dns.DialTimeout("udp", tr.addr, maxDialTimeout)
|
||||
c3, _ := dns.DialTimeout("udp", tr.addr, maxDialTimeout)
|
||||
|
||||
tr.conns["udp"] = []*persistConn{
|
||||
{c1, time.Now()},
|
||||
{c2, time.Now()},
|
||||
{c3, time.Now()},
|
||||
}
|
||||
tr.conns[typeUdp] = []*persistConn{{c1, time.Now()}, {c2, time.Now()}, {c3, time.Now()}}
|
||||
|
||||
if len(tr.conns["udp"]) != 3 {
|
||||
if len(tr.conns[typeUdp]) != 3 {
|
||||
t.Error("Expected 3 connections")
|
||||
}
|
||||
tr.cleanup(true)
|
||||
|
||||
if len(tr.conns["udp"]) > 0 {
|
||||
if len(tr.conns[typeUdp]) > 0 {
|
||||
t.Error("Expected no cached connections")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue