From e3275e9f2a2e2d863260139e8b25b612524c4c7f Mon Sep 17 00:00:00 2001 From: duanhf2012 <6549168@qq.com> Date: Wed, 11 Dec 2024 18:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E5=9D=97=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/module.go | 7 ++++--- service/service.go | 7 +++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/service/module.go b/service/module.go index 33ef4d8..7507d27 100644 --- a/service/module.go +++ b/service/module.go @@ -125,14 +125,15 @@ func (m *Module) AddModule(module IModule) (uint32, error) { func (m *Module) ReleaseModule(moduleId uint32) { pModule := m.GetModule(moduleId).getBaseModule().(*Module) - //释放子孙 + pModule.self.OnRelease() + log.Debug("Release module " + pModule.GetModuleName()) + for i:=len(pModule.child)-1; i>=0; i-- { m.ReleaseModule(pModule.child[i].GetModuleId()) } - pModule.self.OnRelease() pModule.GetEventHandler().Destroy() - log.Debug("Release module " + pModule.GetModuleName()) + for pTimer := range pModule.mapActiveTimer { pTimer.Cancel() } diff --git a/service/service.go b/service/service.go index cfdbcc3..2d10e6d 100644 --- a/service/service.go +++ b/service/service.go @@ -264,12 +264,11 @@ func (s *Service) Release() { } }() - for i:=len(s.child)-1; i>=0; i-- { - s.ReleaseModule(s.child[i].GetModuleId()) - } - if atomic.AddInt32(&s.isRelease, -1) == -1 { s.self.OnRelease() + for i:=len(s.child)-1; i>=0; i-- { + s.ReleaseModule(s.child[i].GetModuleId()) + } } }