Skip to content

Commit ceebe17

Browse files
committed
fix autotune fec mis-align when parameters are different
1 parent b6abd38 commit ceebe17

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

fec.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ type fecDecoder struct {
4545
codec reedsolomon.Encoder
4646

4747
// auto tune fec parameter
48-
autoTune autoTune
48+
autoTune autoTune
49+
shouldTune bool
4950
}
5051

5152
func newFECDecoder(dataShards, parityShards int) *fecDecoder {
@@ -78,18 +79,17 @@ func (dec *fecDecoder) decode(in fecPacket) (recovered [][]byte) {
7879
}
7980

8081
// check if FEC parameters is out of sync
81-
var shouldTune bool
8282
if int(in.seqid())%dec.shardSize < dec.dataShards {
8383
if in.flag() != typeData { // expect typeData
84-
shouldTune = true
84+
dec.shouldTune = true
8585
}
8686
} else {
8787
if in.flag() != typeParity {
88-
shouldTune = true
88+
dec.shouldTune = true
8989
}
9090
}
9191

92-
if shouldTune {
92+
if dec.shouldTune {
9393
autoDS := dec.autoTune.FindPeriod(true)
9494
autoPS := dec.autoTune.FindPeriod(false)
9595

@@ -108,11 +108,17 @@ func (dec *fecDecoder) decode(in fecPacket) (recovered [][]byte) {
108108
dec.codec = codec
109109
dec.decodeCache = make([][]byte, dec.shardSize)
110110
dec.flagCache = make([]bool, dec.shardSize)
111+
dec.shouldTune = false
111112
//log.Println("autotune to :", dec.dataShards, dec.parityShards)
112113
}
113114
}
114115
}
115116

117+
// parameters in tuning
118+
if dec.shouldTune {
119+
return nil
120+
}
121+
116122
// insertion
117123
n := len(dec.rx) - 1
118124
insertIdx := 0

0 commit comments

Comments
 (0)