Commit fa625c69 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Push clients synchronously.

Doing this asynchronously was racy -- under extreme circumstances, a
client could be deleted before it was added.
parent 3c7b3205
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment