加入模块时验证模块id是否重复

This commit is contained in:
boyce
2019-03-22 18:40:58 +08:00
parent 89c7f040c5
commit e1987a1578

View File

@@ -175,6 +175,12 @@ func (slf *BaseModule) AddModule(module IModule) uint32 {
slf.rwModuleLocker = &sync.RWMutex{} slf.rwModuleLocker = &sync.RWMutex{}
} }
pModule := slf.GetModuleById(module.GetModuleId())
if pModule != nil {
GetLogger().Printf(LEVER_ERROR, "%T Cannot AddModule %T,moduleid %d is repeat!", slf.GetSelf(), module.GetSelf(), module.GetModuleId())
return 0
}
locker := slf.GetRoot().getBaseModule().getLocker() locker := slf.GetRoot().getBaseModule().getLocker()
locker.Lock() locker.Lock()
defer locker.Unlock() defer locker.Unlock()