Skip to content

Commit e726178

Browse files
committed
makes a fresh copy of the message before returning
1 parent bfb0416 commit e726178

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

p2p/conn/connection.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (c *MConnection) OnStart() error {
237237
c.quitReceiverManager = make(chan struct{})
238238
go c.sendRoutine()
239239
go c.recvRoutine()
240-
//go c.receiverManager() // start managing the incoming messages based on
240+
go c.receiverManager() // start managing the incoming messages based on
241241
// the channels priorities
242242
return nil
243243
}
@@ -657,7 +657,7 @@ FOR_LOOP:
657657
func (c *MConnection) recvRoutine() {
658658
// their priorities
659659
defer c._recover()
660-
go c.receiverManager()
660+
//go c.receiverManager()
661661

662662
protoReader := protoio.NewDelimitedReader(c.bufConnReader, c._maxPacketMsgSize)
663663

@@ -1000,7 +1000,8 @@ func (ch *Channel) recvPacketMsg(packet tmp2p.PacketMsg) ([]byte, error) {
10001000
// suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes,
10011001
// at which point the recving slice stops being used and should be garbage collected
10021002
ch.recving = ch.recving[:0] // make([]byte, 0, ch.desc.RecvBufferCapacity)
1003-
return msgBytes, nil
1003+
// create a copy of the message bytes to return
1004+
return append([]byte(nil), msgBytes...), nil
10041005
}
10051006
return nil, nil
10061007
}

0 commit comments

Comments
 (0)