mirror of https://github.com/cbeuw/Cloak
Fix issue which the closing frame padding gets send as acutal data
This commit is contained in:
parent
a52c3204d1
commit
cb07e446b6
|
|
@ -73,11 +73,17 @@ func (s *Stream) recvNewFrame() {
|
||||||
|
|
||||||
// when there's no ooo packages in heap and we receive the next package in order
|
// when there's no ooo packages in heap and we receive the next package in order
|
||||||
if len(s.sh) == 0 && f.Seq == s.nextRecvSeq {
|
if len(s.sh) == 0 && f.Seq == s.nextRecvSeq {
|
||||||
s.pushFrame(f)
|
|
||||||
if f.Closing == 1 {
|
if f.Closing == 1 {
|
||||||
// empty data indicates closing signal
|
// empty data indicates closing signal
|
||||||
s.sortedBufCh <- []byte{}
|
s.sortedBufCh <- []byte{}
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
s.sortedBufCh <- f.Payload
|
||||||
|
s.nextRecvSeq += 1
|
||||||
|
if s.nextRecvSeq == 0 { // getting wrapped
|
||||||
|
s.rev += 1
|
||||||
|
s.wrapMode = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -108,23 +114,20 @@ func (s *Stream) recvNewFrame() {
|
||||||
heap.Push(&s.sh, fs)
|
heap.Push(&s.sh, fs)
|
||||||
// Keep popping from the heap until empty or to the point that the wanted seq was not received
|
// Keep popping from the heap until empty or to the point that the wanted seq was not received
|
||||||
for len(s.sh) > 0 && s.sh[0].frame.Seq == s.nextRecvSeq {
|
for len(s.sh) > 0 && s.sh[0].frame.Seq == s.nextRecvSeq {
|
||||||
frame := heap.Pop(&s.sh).(*frameNode).frame
|
f = heap.Pop(&s.sh).(*frameNode).frame
|
||||||
if frame.Closing == 1 {
|
if f.Closing == 1 {
|
||||||
// empty data indicates closing signal
|
// empty data indicates closing signal
|
||||||
s.sortedBufCh <- []byte{}
|
s.sortedBufCh <- []byte{}
|
||||||
return
|
return
|
||||||
|
} else {
|
||||||
|
s.sortedBufCh <- f.Payload
|
||||||
|
s.nextRecvSeq += 1
|
||||||
|
if s.nextRecvSeq == 0 { // getting wrapped
|
||||||
|
s.rev += 1
|
||||||
|
s.wrapMode = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s.pushFrame(frame)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Stream) pushFrame(f *Frame) {
|
|
||||||
s.sortedBufCh <- f.Payload
|
|
||||||
s.nextRecvSeq += 1
|
|
||||||
if s.nextRecvSeq == 0 { // getting wrapped
|
|
||||||
s.rev += 1
|
|
||||||
s.wrapMode = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue