From 7d6687bb91863ca369ec7ebcb48569cb7c1ae747 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 13 Nov 2020 13:29:05 +0800 Subject: [PATCH] 1 --- server/analyseapi/riskmgr.go | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/server/analyseapi/riskmgr.go b/server/analyseapi/riskmgr.go index 88b1091..b4cbd59 100644 --- a/server/analyseapi/riskmgr.go +++ b/server/analyseapi/riskmgr.go @@ -27,7 +27,7 @@ type RiskMgr struct { totalSessionErrBlockTimes int64 sessionErrBlockTimes int64 - gameHash map[int32]*GameConf + gameHash map[int64]*GameConf gameHashMutex sync.RWMutex clusterConf *MtwServerInfo @@ -40,7 +40,7 @@ func (this* RiskMgr) Init() *RiskMgr { defer this.gameHashMutex.Unlock() this.fixedBlockProvinceCityHash = make(map[string]int32) - this.gameHash = make(map[int32]*GameConf) + this.gameHash = make(map[int64]*GameConf) for _, val := range G.MetaMgr.GetFixedBlockProvinceCity().GetList() { this.fixedBlockProvinceCityHash[val] = 1 } @@ -122,12 +122,21 @@ func (this* RiskMgr) GetSdkInfo(accessKeyId* string, accessSecret* string) { *accessSecret = "" + this.accessSecret } -func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf { - return nil +func (this *RiskMgr) ForceGameConf(gameId int32, channel int32) *GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + if val, ok := this.gameHash[q5.MkInt64(gameId, channel)]; ok { + return val + } else { + return nil + } } -func (this *RiskMgr) GetGameConfEx(gameId int32, channel int32) *GameConf { - return nil +func (this *RiskMgr) GetGameConf(gameId int32, channel int32) *GameConf { + this.gameHashMutex.Lock() + defer this.gameHashMutex.Unlock() + val, _ := this.gameHash[q5.MkInt64(gameId, channel)] + return val } func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { @@ -149,7 +158,7 @@ func (this *RiskMgr) __analyseIsOpen(w* http.ResponseWriter, r *http.Request) { gameId := f5.ExtractGameIdFromAccountId(accountId) channel := f5.ExtractChannelFromAccountId(accountId) - gameConf = this.GetGameConf(gameId, channel) + gameConf = this.ForceGameConf(gameId, channel) if gameConf == nil { return false }