mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
⚡️ refactor: 将排序的服务器列表的锁拆分出来
This commit is contained in:
@@ -90,8 +90,8 @@ func (p *commonPage) service(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (cp *commonPage) home(c *gin.Context) {
|
||||
dao.ServerLock.RLock()
|
||||
defer dao.ServerLock.RUnlock()
|
||||
dao.SortedServerLock.RLock()
|
||||
defer dao.SortedServerLock.RUnlock()
|
||||
|
||||
c.HTML(http.StatusOK, "theme-"+dao.Conf.Site.Theme+"/home", mygin.CommonEnvironment(c, gin.H{
|
||||
"Servers": dao.SortedServerList,
|
||||
@@ -115,9 +115,9 @@ func (cp *commonPage) ws(c *gin.Context) {
|
||||
}
|
||||
defer conn.Close()
|
||||
for {
|
||||
dao.ServerLock.RLock()
|
||||
dao.SortedServerLock.RLock()
|
||||
err = conn.WriteJSON(dao.SortedServerList)
|
||||
dao.ServerLock.RUnlock()
|
||||
dao.SortedServerLock.RUnlock()
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user