瀏覽代碼

fix a bug in length calculation

v2ray 9 年之前
父節點
當前提交
2169dcd7da
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      transport/internet/kcp/sending.go

+ 10 - 9
transport/internet/kcp/sending.go

@@ -60,16 +60,17 @@ func (this *SendingWindow) Remove(idx uint32) {
 	}
 	seg.Release()
 	this.data[pos] = nil
-	if pos == this.start {
-		if this.start == this.last {
-			this.len = 0
-			this.start = 0
-			this.last = 0
-		} else {
-			delta := this.next[pos] - this.start
-			this.start = this.next[pos]
-			this.len -= delta
+	if pos == this.start && pos == this.last {
+		this.len = 0
+		this.start = 0
+		this.last = 0
+	} else if pos == this.start {
+		delta := this.next[pos] - this.start
+		if this.next[pos] < this.start {
+			delta = this.next[pos] + this.cap - this.start
 		}
+		this.start = this.next[pos]
+		this.len -= delta
 	} else if pos == this.last {
 		this.last = this.prev[pos]
 	} else {