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]
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue