1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00

correctly calculate len of sending window

This commit is contained in:
v2ray 2016-07-01 15:54:04 +02:00
parent 5714ae3935
commit 829355e6bf
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 12 additions and 1 deletions

View File

@ -61,7 +61,7 @@ func (this *SendingWindow) Remove(idx uint32) {
seg.Release() seg.Release()
this.data[pos] = nil this.data[pos] = nil
if pos == this.start { if pos == this.start {
if this.len == 1 { if this.start == this.last {
this.len = 0 this.len = 0
this.start = 0 this.start = 0
this.last = 0 this.last = 0

View File

@ -94,4 +94,15 @@ func TestSendingWindow(t *testing.T) {
}) })
assert.Int(window.Len()).Equals(1) assert.Int(window.Len()).Equals(1)
assert.Uint32(window.First().Number).Equals(4) assert.Uint32(window.First().Number).Equals(4)
window.Push(&DataSegment{
Number: 5,
})
assert.Int(window.Len()).Equals(2)
window.Remove(1)
assert.Int(window.Len()).Equals(2)
window.Remove(0)
assert.Int(window.Len()).Equals(0)
} }