Skip to content

Commit

Permalink
fix oom
Browse files Browse the repository at this point in the history
  • Loading branch information
windycrypto committed Nov 29, 2023
1 parent 8eff606 commit dcdc943
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions relay/wshandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,15 @@ func (ws *WsServer) handleClientDisconnect(client *client) {
channelsToClear = append(channelsToClear, messageChanKey(topic))
}
}

if client.role == Dapp {
// clear dapp notify channels
publishedChannels := []string{}
for topic := range client.pubTopics.Get() {
ws.publishers.Unset(topic, client)
if ws.publishers.Len(topic) == 0 {
publishedChannels = append(publishedChannels, dappNotifyChanKey(topic))
for topic := range client.pubTopics.Get() {
ws.publishers.Unset(topic, client)
if ws.publishers.Len(topic) == 0 {
channelsToClear = append(channelsToClear, messageChanKey(topic))
// for dapp, need to further clear notify channels
if client.role == Dapp {
channelsToClear = append(channelsToClear, dappNotifyChanKey(topic))
}
}
channelsToClear = append(channelsToClear, publishedChannels...)
}

if len(channelsToClear) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion relay/wsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (ws *WsServer) NewClientConn(w http.ResponseWriter, r *http.Request) {
ws: ws,
pubTopics: NewTopicSet(),
subTopics: NewTopicSet(),
sendbuf: make(chan SocketMessage, 256),
sendbuf: make(chan SocketMessage, 8),
quit: make(chan struct{}),
}

Expand Down

0 comments on commit dcdc943

Please sign in to comment.