fix: fixing memory leak from unbuffered channel

This commit is contained in:
2025-10-07 09:16:51 +07:00
parent 78a5b21531
commit 88ae539f54
3 changed files with 9 additions and 9 deletions

View File

@@ -23,9 +23,9 @@ type Client struct {
func NewClient(conn *websocket.Conn, subscribedPath string) *Client {
return &Client{
Conn: conn,
Send: make(chan []byte, 64),
Send: make(chan []byte, 2),
SubscribedPath: subscribedPath,
done: make(chan struct{}),
done: make(chan struct{}, 1),
}
}
@@ -38,10 +38,10 @@ type Hub struct {
func NewHub() *Hub {
return &Hub{
Broadcast: make(chan []byte),
Register: make(chan *Client),
Unregister: make(chan *Client),
Clients: make(map[*Client]bool),
Broadcast: make(chan []byte, 1),
Register: make(chan *Client, 1),
Unregister: make(chan *Client, 1),
Clients: make(map[*Client]bool, 1),
}
}