This commit is contained in:
aozhiwei 2024-07-24 18:51:46 +08:00
parent a82677e4df
commit 7f38d722b4
3 changed files with 7 additions and 3 deletions

View File

@ -26,6 +26,8 @@ func CaForward(c *gin.Context) {
return
}
cLock := service.SApiForward.AcquireLock(accountId)
defer service.SApiForward.ReleaseLock(cLock)
service.SApiForward.IncTotalTimes()
beginTick := q5.GetTickCount()
defer func() {

View File

@ -90,12 +90,13 @@ func (this *sApiForward) UpdateCostTime(costTime int64) {
func (this *sApiForward) getOrCreate(c *SApiForwardLockCache, accountId string) *SApiForwardLock {
c.lock.Lock()
defer c.lock.Lock()
defer c.lock.Unlock()
if u, ok := (*c.userHash)[accountId]; ok {
return u
} else {
u = new(SApiForwardLock)
u.accountId = accountId
u.lock = new(sync.Mutex)
return u
}
}

View File

@ -4,9 +4,10 @@ type serviceMgr struct {
}
func (this *serviceMgr) Init() {
SApiForward = new(sApiForward)
SApiForward.init()
}
func (this *serviceMgr) UnInit() {
SApiForward.unInit()
}