1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-14 04:35:57 +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.clients[c.Id()] = c
g.timestamp = time.Now() g.timestamp = time.Now()
go func(clients []Client) { u := c.Username()
u := c.Username() c.PushClient(c.Id(), u, true)
c.PushClient(c.Id(), u, true) for _, c := range clients {
for _, cc := range clients { for _, cc := range clients {
uu := cc.Username() c.PushClient(cc.Id(), cc.Username(), true)
c.PushClient(cc.Id(), uu, true)
cc.PushClient(c.Id(), u, true) cc.PushClient(c.Id(), u, true)
} }
}(clients) }
return g, nil return g, nil
} }