浏览代码

re-init maps when they are empty

Darien Raymond 7 年之前
父节点
当前提交
83625618ee
共有 3 个文件被更改,包括 12 次插入0 次删除
  1. 4 0
      app/dns/server.go
  2. 4 0
      app/proxyman/mux/session.go
  3. 4 0
      proxy/vmess/encoding/server.go

+ 4 - 0
app/dns/server.go

@@ -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) {

+ 4 - 0
app/proxyman/mux/session.go

@@ -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) {

+ 4 - 0
proxy/vmess/encoding/server.go

@@ -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 {