File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -290,3 +290,10 @@ func (c *Conn) RemotePub() *btcec.PublicKey {
290
290
func (c * Conn ) LocalPub () * btcec.PublicKey {
291
291
return c .noise .localStatic .PubKey ()
292
292
}
293
+
294
+ // ClearPendingSend drops references to the next header and body buffers so
295
+ // that the memory can be garbage collected.
296
+ func (c * Conn ) ClearPendingSend () {
297
+ c .noise .nextHeaderSend = nil
298
+ c .noise .nextBodySend = nil
299
+ }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import (
19
19
"github.com/btcsuite/btcd/txscript"
20
20
"github.com/btcsuite/btcd/wire"
21
21
"github.com/btcsuite/btclog/v2"
22
+ "github.com/lightningnetwork/lnd/brontide"
22
23
"github.com/lightningnetwork/lnd/buffer"
23
24
"github.com/lightningnetwork/lnd/chainntnfs"
24
25
"github.com/lightningnetwork/lnd/channeldb"
@@ -2705,6 +2706,13 @@ out:
2705
2706
goto retry
2706
2707
}
2707
2708
2709
+ // Message has either been successfully sent or an
2710
+ // unrecoverable error occurred. Either way, we can
2711
+ // free the memory used to store the message.
2712
+ if bConn , ok := p .cfg .Conn .(* brontide.Conn ); ok {
2713
+ bConn .ClearPendingSend ()
2714
+ }
2715
+
2708
2716
// The write succeeded, reset the idle timer to prevent
2709
2717
// us from disconnecting the peer.
2710
2718
if ! idleTimer .Stop () {
You can’t perform that action at this time.
0 commit comments