From 785775a928d5136f6de50e02504b9289b30df728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=BF=97=E5=AE=87?= Date: Mon, 10 Jun 2019 20:55:14 +0800 Subject: [PATCH] Changed dmsg.Transport default buffer sizes. --- pkg/dmsg/frame.go | 11 ++++++----- pkg/dmsg/transport.go | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pkg/dmsg/frame.go b/pkg/dmsg/frame.go index 27c7af601..1c68fab68 100644 --- a/pkg/dmsg/frame.go +++ b/pkg/dmsg/frame.go @@ -17,11 +17,12 @@ const ( // Type returns the transport type string. Type = "dmsg" - hsTimeout = time.Second * 10 - tpBufCap = math.MaxUint16 - tpAckCap = math.MaxUint8 - acceptChSize = 20 - headerLen = 5 // fType(1 byte), chID(2 byte), payLen(2 byte) + hsTimeout = time.Second * 10 + tpBufCap = math.MaxUint16 + tpBufFrameCap = math.MaxUint8 + tpAckCap = math.MaxUint8 + acceptChSize = 20 + headerLen = 5 // fType(1 byte), chID(2 byte), payLen(2 byte) ) func isInitiatorID(tpID uint16) bool { return tpID%2 == 0 } diff --git a/pkg/dmsg/transport.go b/pkg/dmsg/transport.go index 8dd076ecd..97095ec29 100644 --- a/pkg/dmsg/transport.go +++ b/pkg/dmsg/transport.go @@ -57,6 +57,7 @@ func NewTransport(conn net.Conn, log *logging.Logger, local, remote cipher.PubKe remote: remote, inCh: make(chan Frame), ackBuf: make([]byte, 0, tpAckCap), + buf: make(net.Buffers, 0, tpBufFrameCap), bufCh: make(chan struct{}, 1), done: make(chan struct{}), doneFunc: doneFunc,