rename MaxReceivePacketSize to MaxPacketBufferSize

We use the same buffer size for sending and receiving packets.
This commit is contained in:
Marten Seemann
2021-01-25 16:46:35 +08:00
parent fb5a45ac53
commit 82ac6dcf6d
14 changed files with 26 additions and 26 deletions

View File

@@ -11,7 +11,7 @@ var pool sync.Pool
func init() {
pool.New = func() interface{} {
return &StreamFrame{
Data: make([]byte, 0, protocol.MaxReceivePacketSize),
Data: make([]byte, 0, protocol.MaxPacketBufferSize),
fromPool: true,
}
}
@@ -26,7 +26,7 @@ func putStreamFrame(f *StreamFrame) {
if !f.fromPool {
return
}
if protocol.ByteCount(cap(f.Data)) != protocol.MaxReceivePacketSize {
if protocol.ByteCount(cap(f.Data)) != protocol.MaxPacketBufferSize {
panic("wire.PutStreamFrame called with packet of wrong size!")
}
pool.Put(f)

View File

@@ -82,9 +82,9 @@ var _ = Describe("STREAM frame", func() {
It("rejects frames that claim to be longer than the packet size", func() {
data := []byte{0x8 ^ 0x2}
data = append(data, encodeVarInt(0x12345)...) // stream ID
data = append(data, encodeVarInt(uint64(protocol.MaxReceivePacketSize)+1)...) // data length
data = append(data, make([]byte, protocol.MaxReceivePacketSize+1)...)
data = append(data, encodeVarInt(0x12345)...) // stream ID
data = append(data, encodeVarInt(uint64(protocol.MaxPacketBufferSize)+1)...) // data length
data = append(data, make([]byte, protocol.MaxPacketBufferSize+1)...)
r := bytes.NewReader(data)
_, err := parseStreamFrame(r, versionIETFFrames)
Expect(err).To(Equal(io.EOF))

View File

@@ -335,7 +335,7 @@ func (p *TransportParameters) Marshal(pers protocol.Perspective) []byte {
// idle_timeout
p.marshalVarintParam(b, maxIdleTimeoutParameterID, uint64(p.MaxIdleTimeout/time.Millisecond))
// max_packet_size
p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(protocol.MaxReceivePacketSize))
p.marshalVarintParam(b, maxUDPPayloadSizeParameterID, uint64(protocol.MaxPacketBufferSize))
// max_ack_delay
// Only send it if is different from the default value.
if p.MaxAckDelay != protocol.DefaultMaxAckDelay {