1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-22 23:35:46 +01:00

Push clients synchronously.

Doing this asynchronously was racy -- under extreme circumstances, a
client could be deleted before it was added.
This commit is contained in:
Juliusz Chroboczek 2021-02-14 16:40:21 +01:00
parent 3c7b32056b
commit fa625c693e

View file

@ -485,15 +485,14 @@ func AddClient(group string, c Client) (*Group, error) {
g.clients[c.Id()] = c
g.timestamp = time.Now()
go func(clients []Client) {
u := c.Username()
c.PushClient(c.Id(), u, true)
u := c.Username()
c.PushClient(c.Id(), u, true)
for _, c := range clients {
for _, cc := range clients {
uu := cc.Username()
c.PushClient(cc.Id(), uu, true)
c.PushClient(cc.Id(), cc.Username(), true)
cc.PushClient(c.Id(), u, true)
}
}(clients)
}
return g, nil
}