1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 10:22:19 +00:00

Avoid concurrent map read/write

This commit is contained in:
Yohann D'ANELLO 2020-11-09 18:03:15 +01:00
parent b2104a0cb7
commit d1c4f81f4e

View File

@ -107,11 +107,15 @@ func statisticsHandler(w http.ResponseWriter, r *http.Request) {
uid := r.URL.Query()["uid"][0]
connectedClients[name][uid] = currentTime
}
toDelete := make([]string, 0)
for uid, oldTime := range connectedClients[name] {
if currentTime-oldTime > 40 {
delete(connectedClients, uid)
toDelete = append(toDelete, uid)
}
}
for _, uid := range toDelete {
delete(connectedClients[name], uid)
}
// Get requested stream
stream, err := streams.Get(name)