瀏覽代碼

update RecivingWindow.Remove

v2ray 9 年之前
父節點
當前提交
231f5fc140
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 0 3
      transport/internet/kcp/receiving.go
  2. 4 0
      transport/internet/kcp/receiving_test.go

+ 0 - 3
transport/internet/kcp/receiving.go

@@ -33,9 +33,6 @@ func (this *ReceivingWindow) Set(idx uint32, value *Segment) bool {
 
 func (this *ReceivingWindow) Remove(idx uint32) *Segment {
 	pos := this.Position(idx)
-	if this.list[pos] == nil {
-		return nil
-	}
 	e := this.list[pos]
 	this.list[pos] = nil
 	return e

+ 4 - 0
transport/internet/kcp/receiving_test.go

@@ -19,6 +19,10 @@ func TestRecivingWindow(t *testing.T) {
 
 	assert.Bool(window.Set(0, seg0)).IsTrue()
 	assert.Pointer(window.RemoveFirst()).Equals(seg0)
+	e := window.RemoveFirst()
+	if e != nil {
+		assert.Fail("Expecting nil.")
+	}
 
 	assert.Bool(window.Set(1, seg1)).IsTrue()
 	assert.Bool(window.Set(2, seg2)).IsTrue()