re-init maps when they are empty

pull/1028/head
Darien Raymond 2018-04-07 23:07:30 +02:00
parent deb7dab8f3
commit 83625618ee
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 12 additions and 0 deletions

View File

@ -105,6 +105,10 @@ func (s *Server) cleanup() {
delete(s.records, d) delete(s.records, d)
} }
} }
if len(s.records) == 0 {
s.records = make(map[string]*DomainRecord)
}
} }
func (s *Server) LookupIP(domain string) ([]net.IP, error) { func (s *Server) LookupIP(domain string) ([]net.IP, error) {

View File

@ -73,6 +73,10 @@ func (m *SessionManager) Remove(id uint16) {
} }
delete(m.sessions, id) delete(m.sessions, id)
if len(m.sessions) == 0 {
m.sessions = make(map[uint16]*Session, 16)
}
} }
func (m *SessionManager) Get(id uint16) (*Session, bool) { func (m *SessionManager) Get(id uint16) (*Session, bool) {

View File

@ -78,6 +78,10 @@ func (h *SessionHistory) removeExpiredEntries() {
delete(h.cache, session) delete(h.cache, session)
} }
} }
if len(h.cache) == 0 {
h.cache = make(map[sessionId]time.Time, 128)
}
} }
type ServerSession struct { type ServerSession struct {