mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 04:07:35 +03:00
put back packet buffers after processing a packet
This introduces a reference counter in the packet buffer, which will be used to process coalesced packets.
This commit is contained in:
parent
413844d0bc
commit
767dbdd545
9 changed files with 135 additions and 71 deletions
|
@ -9,13 +9,24 @@ import (
|
|||
|
||||
var _ = Describe("Buffer Pool", func() {
|
||||
It("returns buffers of cap", func() {
|
||||
buf := *getPacketBuffer()
|
||||
Expect(buf).To(HaveCap(int(protocol.MaxReceivePacketSize)))
|
||||
buf := getPacketBuffer()
|
||||
Expect(buf.Slice).To(HaveCap(int(protocol.MaxReceivePacketSize)))
|
||||
})
|
||||
|
||||
It("puts buffers back", func() {
|
||||
buf := getPacketBuffer()
|
||||
putPacketBuffer(buf)
|
||||
})
|
||||
|
||||
It("panics if wrong-sized buffers are passed", func() {
|
||||
Expect(func() {
|
||||
putPacketBuffer(&[]byte{0})
|
||||
}).To(Panic())
|
||||
buf := getPacketBuffer()
|
||||
buf.Slice = make([]byte, 10)
|
||||
Expect(func() { putPacketBuffer(buf) }).To(Panic())
|
||||
})
|
||||
|
||||
It("panics if it is put pack twice", func() {
|
||||
buf := getPacketBuffer()
|
||||
putPacketBuffer(buf)
|
||||
Expect(func() { putPacketBuffer(buf) }).To(Panic())
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue