修复UserAgent分析可能产生的死锁

This commit is contained in:
GoEdgeLab
2023-05-19 20:11:53 +08:00
parent 7bd653239e
commit e29f9d7008

View File

@@ -68,6 +68,8 @@ func (this *UserAgentParser) Parse(userAgent string) (result UserAgentParserResu
this.locker.RUnlock() this.locker.RUnlock()
this.locker.Lock() this.locker.Lock()
defer this.locker.Unlock()
this.parser.Parse(userAgent) this.parser.Parse(userAgent)
result.OS = this.parser.OSInfo() result.OS = this.parser.OSInfo()
result.BrowserName, result.BrowserVersion = this.parser.Browser() result.BrowserName, result.BrowserVersion = this.parser.Browser()
@@ -95,7 +97,6 @@ func (this *UserAgentParser) Parse(userAgent string) (result UserAgentParserResu
this.cacheMap1 = map[string]UserAgentParserResult{} this.cacheMap1 = map[string]UserAgentParserResult{}
} }
} }
this.locker.Unlock()
return return
} }