mirror of
https://gitlab.crans.org/nounous/ghostream.git
synced 2024-12-22 17:22:20 +00:00
Avoid concurrent map read/write
This commit is contained in:
parent
b2104a0cb7
commit
d1c4f81f4e
@ -107,11 +107,15 @@ func statisticsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
uid := r.URL.Query()["uid"][0]
|
uid := r.URL.Query()["uid"][0]
|
||||||
connectedClients[name][uid] = currentTime
|
connectedClients[name][uid] = currentTime
|
||||||
}
|
}
|
||||||
|
toDelete := make([]string, 0)
|
||||||
for uid, oldTime := range connectedClients[name] {
|
for uid, oldTime := range connectedClients[name] {
|
||||||
if currentTime-oldTime > 40 {
|
if currentTime-oldTime > 40 {
|
||||||
delete(connectedClients, uid)
|
toDelete = append(toDelete, uid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, uid := range toDelete {
|
||||||
|
delete(connectedClients[name], uid)
|
||||||
|
}
|
||||||
|
|
||||||
// Get requested stream
|
// Get requested stream
|
||||||
stream, err := streams.Get(name)
|
stream, err := streams.Get(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user