fix: data race in PushChatHistory WebSocket writes
This commit is contained in:
1 parent
887023a491
commit
587561f9fc
1 file changed
+2
@@ -105,9 +105,11 @@ func (h *Hub) PushChatHistory(conn *websocket.Conn, room string, limit int) {
|
||||
opp := len(messages) - 1 - i
|
||||
messages[i], messages[opp] = messages[opp], messages[i]
|
||||
}
|
||||
h.mu.Lock()
|
||||
for _, msg := range messages {
|
||||
conn.WriteJSON(msg)
|
||||
}
|
||||
h.mu.Unlock()
|
||||
}
|
||||
|
||||
// HandleConnection handles a new WebSocket connection.
|
||||
|
||||
Reference in new issue
Block a user