mirror of https://github.com/XTLS/Xray-core
API: Fix data race in online ipList
parent
2cba2c4d59
commit
e866ce187f
|
@ -40,11 +40,11 @@ func (c *OnlineMap) AddIP(ip string) {
|
||||||
if ip == "127.0.0.1" {
|
if ip == "127.0.0.1" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, ok := list[ip]; !ok {
|
|
||||||
c.access.Lock()
|
c.access.Lock()
|
||||||
|
if _, ok := list[ip]; !ok {
|
||||||
list[ip] = time.Now()
|
list[ip] = time.Now()
|
||||||
c.access.Unlock()
|
|
||||||
}
|
}
|
||||||
|
c.access.Unlock()
|
||||||
if time.Since(c.lastCleanup) > c.cleanupPeriod {
|
if time.Since(c.lastCleanup) > c.cleanupPeriod {
|
||||||
list = c.RemoveExpiredIPs(list)
|
list = c.RemoveExpiredIPs(list)
|
||||||
c.lastCleanup = time.Now()
|
c.lastCleanup = time.Now()
|
||||||
|
|
Loading…
Reference in New Issue