修复查找域名对应服务时可能造成的死锁

This commit is contained in:
GoEdgeLab
2021-11-17 21:57:03 +08:00
parent d75a28a016
commit 37c02a47ca
2 changed files with 5 additions and 0 deletions

View File

@@ -157,6 +157,7 @@ func (this *ServerAddressGroup) MatchServerName(serverName string) *ServerConfig
if ok {
server, ok := domainMap[serverName]
if ok {
this.cacheLocker.RUnlock()
return server
}
}

View File

@@ -75,6 +75,10 @@ func TestServerAddressGroup_MatchServerName(t *testing.T) {
for i := 0; i < 100_000; i++ {
_ = group.MatchServerName("world.hello.com")
}
// 检查死锁问题
group.MatchServerName("world2.hello.com")
}
func TestServerAddressGroup_MatchServerCNAME(t *testing.T) {