fix: 修复 server.Server 在使用 UseShunt 函数时由于未记录当前分发器导致的内存泄漏问题

This commit is contained in:
kercylan98
2023-12-20 11:24:51 +08:00
parent e60017c0eb
commit 7e09229330
3 changed files with 6 additions and 8 deletions

View File

@@ -596,6 +596,7 @@ func (slf *Server) UseShunt(conn *Conn, name string) {
delete(slf.dispatchers, curr.name)
}
}
slf.currDispatcher[conn.GetID()] = d
member, exist := slf.dispatcherMember[name]
if !exist {

View File

@@ -24,6 +24,9 @@ func TestNew(t *testing.T) {
fmt.Println("关闭", conn.GetID(), err, "Count", srv.GetOnlineCount())
})
srv.RegConnectionOpenedEvent(func(srv *server.Server, conn *server.Conn) {
srv.UseShunt(conn, "1")
srv.UseShunt(conn, "2")
srv.UseShunt(conn, "3")
//if srv.GetOnlineCount() > 1 {
// conn.Close()
//}