Skip to content

Commit

Permalink
try fixing memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
windycrypto committed Nov 27, 2023
1 parent 5b01ab4 commit a225994
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 0 additions & 3 deletions relay/wsconn.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package relay
import (
"bytes"
"encoding/json"
"fmt"
"strings"

"github.com/RabbyHub/derelay/log"
Expand Down Expand Up @@ -31,7 +30,6 @@ func (c *client) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
if c != nil {
encoder.AddString("id", c.id)
encoder.AddString("role", string(c.role))
encoder.AddString("session", string(c.session))
encoder.AddArray("pubTopics", c.pubTopics)
encoder.AddArray("subTopics", c.subTopics)
}
Expand Down Expand Up @@ -87,7 +85,6 @@ func (c *client) send(message SocketMessage) {
case c.sendbuf <- message:
default:
metrics.IncSendBlocking()
log.Error("client sendbuf full", fmt.Errorf(""), zap.Any("client", c), zap.Any("len(sendbuf)", len(c.sendbuf)), zap.Any("message", message))
}
}

Expand Down
6 changes: 3 additions & 3 deletions relay/wshandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ func (ws *WsServer) subMessage(message SocketMessage) {
if err := ws.redisSubConn.Subscribe(context.TODO(), messageChanKey(topic)); err != nil {
log.Warn("[redisSub] subscribe to topic fail", zap.String("topic", topic), zap.Any("client", subscriber))
}
log.Info("subscribe to topic", zap.String("topic", topic), zap.Any("client", subscriber))
//log.Info("subscribe to topic", zap.String("topic", topic), zap.Any("client", subscriber))

// forward cached notificatoins if there's any
notifications := ws.getCachedMessages(topic, true)
log.Info("pending notifications", zap.String("topic", topic), zap.Any("num", len(notifications)), zap.Any("client", subscriber))
//log.Info("pending notifications", zap.String("topic", topic), zap.Any("num", len(notifications)), zap.Any("client", subscriber))
for _, notification := range notifications {
subscriber.send(notification)
}
Expand All @@ -84,7 +84,7 @@ func (ws *WsServer) subMessage(message SocketMessage) {
if noti.Phase == string(SessionRequest) { // handle the 1st case stated above
subscriber.session = noti.Topic
metrics.IncReceivedSessions()
log.Info("session been scanned", zap.Any("topic", topic), zap.Any("client", subscriber))
//log.Info("session been scanned", zap.Any("topic", topic), zap.Any("client", subscriber))

// notify the topic publisher, aka the dapp, that the session request has been received by wallet
key := dappNotifyChanKey(noti.Topic)
Expand Down

0 comments on commit a225994

Please sign in to comment.