-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kcptun: fixed a bug in fec tuning when fec parameters on client & server
side are set differently.
- Loading branch information
1 parent
aea7e25
commit 20f3f8e
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
package/extra/kcptun/patches/0001-fix-autotune-fec-mis-align-when-parameters-are-diffe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
From 3e301afd05787b5a61edf22006a029254ee36c24 Mon Sep 17 00:00:00 2001 | ||
From: xtaci <[email protected]> | ||
Date: Thu, 12 Oct 2023 23:29:36 +0800 | ||
Subject: [PATCH] fix autotune fec mis-align when parameters are different | ||
|
||
--- | ||
vendor/github.com/xtaci/kcp-go/v5/fec.go | 16 +++++++++++----- | ||
1 file changed, 11 insertions(+), 5 deletions(-) | ||
|
||
diff --git a/vendor/github.com/xtaci/kcp-go/v5/fec.go b/vendor/github.com/xtaci/kcp-go/v5/fec.go | ||
index 0a203ee..af02ed8 100644 | ||
--- a/vendor/github.com/xtaci/kcp-go/v5/fec.go | ||
+++ b/vendor/github.com/xtaci/kcp-go/v5/fec.go | ||
@@ -48,7 +48,8 @@ type fecDecoder struct { | ||
codec reedsolomon.Encoder | ||
|
||
// auto tune fec parameter | ||
- autoTune autoTune | ||
+ autoTune autoTune | ||
+ shouldTune bool | ||
} | ||
|
||
func newFECDecoder(dataShards, parityShards int) *fecDecoder { | ||
@@ -82,18 +83,17 @@ func (dec *fecDecoder) decode(in fecPacket) (recovered [][]byte) { | ||
} | ||
|
||
// check if FEC parameters is out of sync | ||
- var shouldTune bool | ||
if int(in.seqid())%dec.shardSize < dec.dataShards { | ||
if in.flag() != typeData { // expect typeData | ||
- shouldTune = true | ||
+ dec.shouldTune = true | ||
} | ||
} else { | ||
if in.flag() != typeParity { | ||
- shouldTune = true | ||
+ dec.shouldTune = true | ||
} | ||
} | ||
|
||
- if shouldTune { | ||
+ if dec.shouldTune { | ||
autoDS := dec.autoTune.FindPeriod(true) | ||
autoPS := dec.autoTune.FindPeriod(false) | ||
|
||
@@ -112,11 +112,17 @@ func (dec *fecDecoder) decode(in fecPacket) (recovered [][]byte) { | ||
dec.codec = codec | ||
dec.decodeCache = make([][]byte, dec.shardSize) | ||
dec.flagCache = make([]bool, dec.shardSize) | ||
+ dec.shouldTune = false | ||
//log.Println("autotune to :", dec.dataShards, dec.parityShards) | ||
} | ||
} | ||
} | ||
|
||
+ // parameters in tuning | ||
+ if dec.shouldTune { | ||
+ return nil | ||
+ } | ||
+ | ||
// insertion | ||
n := len(dec.rx) - 1 | ||
insertIdx := 0 | ||
-- | ||
2.25.1 | ||
|