修改动态加载module出现锁被重置

This commit is contained in:
boyce
2019-04-04 20:23:39 +08:00
parent 87bfdaeaf0
commit b0cdc46920
2 changed files with 5 additions and 7 deletions

View File

@@ -51,7 +51,7 @@ type BaseModule struct {
CurrMaxModuleId uint32
corouterstatus int32 //0表示运行状态 //1释放消亡状态
rwModuleLocker *sync.RWMutex
rwModuleLocker *sync.Mutex
ExitChan chan bool
WaitGroup *sync.WaitGroup
bInit bool
@@ -71,7 +71,7 @@ func (slf *BaseModule) GetRoot() IModule {
}
}
func (slf *BaseModule) getLocker() *sync.RWMutex {
func (slf *BaseModule) getLocker() *sync.Mutex {
return slf.rwModuleLocker
}
@@ -181,11 +181,6 @@ func (slf *BaseModule) AddModule(module IModule) uint32 {
return 0
}
if slf.IsRoot() {
//构建Root结点
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())

View File

@@ -2,6 +2,7 @@ package service
import (
"fmt"
"sync"
"reflect"
"strings"
@@ -80,5 +81,7 @@ func (slf *BaseService) Init(iservice IService) error {
}
slf.serviceid = InstanceServiceMgr().GenServiceID()
slf.BaseModule.rwModuleLocker = &sync.Mutex{}
return nil
}