mirror of
https://github.com/xtaci/kcp-go.git
synced 2024-04-21 12:32:15 +00:00
fix autotune fec mis-align when parameters are different
This commit is contained in:
@@ -45,7 +45,8 @@ type fecDecoder struct {
|
||||
codec reedsolomon.Encoder
|
||||
|
||||
// auto tune fec parameter
|
||||
autoTune autoTune
|
||||
autoTune autoTune
|
||||
shouldTune bool
|
||||
}
|
||||
|
||||
func newFECDecoder(dataShards, parityShards int) *fecDecoder {
|
||||
@@ -78,18 +79,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)
|
||||
|
||||
@@ -108,11 +108,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
|
||||
|
||||
Reference in New Issue
Block a user