fix packet buffer usage when handling coalesced packets

This commit is contained in:
Marten Seemann 2019-03-05 13:14:46 +09:00
parent 896d2da380
commit 33bf79c735
3 changed files with 38 additions and 13 deletions

View file

@ -30,14 +30,20 @@ var _ = Describe("Buffer Pool", func() {
Expect(func() { buf.Release() }).To(Panic())
})
It("panics if it is decremented too many times", func() {
buf := getPacketBuffer()
buf.Decrement()
Expect(func() { buf.Decrement() }).To(Panic())
})
It("waits until all parts have been released", func() {
buf := getPacketBuffer()
buf.Split()
buf.Split()
// now we have 3 parts
buf.Release()
buf.Release()
buf.Release()
Expect(func() { buf.Release() }).To(Panic())
buf.Decrement()
buf.Decrement()
buf.Decrement()
Expect(func() { buf.Decrement() }).To(Panic())
})
})