mirror of https://github.com/cbeuw/Cloak
Receiving a closing frame no longer returns error on Write
This commit is contained in:
parent
0bc48a5a2e
commit
3bfaa5c1c1
|
|
@ -64,6 +64,7 @@ func (d *datagramBuffer) Write(f Frame) error {
|
||||||
}
|
}
|
||||||
d.rwCond.Wait()
|
d.rwCond.Wait()
|
||||||
}
|
}
|
||||||
|
// TODO: deal with closing frame here
|
||||||
data := make([]byte, len(f.Payload))
|
data := make([]byte, len(f.Payload))
|
||||||
copy(data, f.Payload)
|
copy(data, f.Payload)
|
||||||
d.buf = append(d.buf, data)
|
d.buf = append(d.buf, data)
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ package multiplex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/heap"
|
"container/heap"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
@ -60,8 +59,6 @@ func NewStreamBuffer() *streamBuffer {
|
||||||
return sb
|
return sb
|
||||||
}
|
}
|
||||||
|
|
||||||
var ClosingFrameReceived = errors.New("closed by closing frame")
|
|
||||||
|
|
||||||
// recvNewFrame is a forever running loop which receives frames unordered,
|
// recvNewFrame is a forever running loop which receives frames unordered,
|
||||||
// cache and order them and send them into sortedBufCh
|
// cache and order them and send them into sortedBufCh
|
||||||
func (sb *streamBuffer) Write(f Frame) error {
|
func (sb *streamBuffer) Write(f Frame) error {
|
||||||
|
|
@ -70,9 +67,8 @@ func (sb *streamBuffer) Write(f Frame) error {
|
||||||
// when there'fs no ooo packages in heap and we receive the next package in order
|
// when there'fs no ooo packages in heap and we receive the next package in order
|
||||||
if len(sb.sh) == 0 && f.Seq == sb.nextRecvSeq {
|
if len(sb.sh) == 0 && f.Seq == sb.nextRecvSeq {
|
||||||
if f.Closing == 1 {
|
if f.Closing == 1 {
|
||||||
// empty data indicates closing signal
|
|
||||||
sb.buf.Close()
|
sb.buf.Close()
|
||||||
return ClosingFrameReceived
|
return nil
|
||||||
} else {
|
} else {
|
||||||
sb.buf.Write(f.Payload)
|
sb.buf.Write(f.Payload)
|
||||||
sb.nextRecvSeq += 1
|
sb.nextRecvSeq += 1
|
||||||
|
|
@ -91,7 +87,7 @@ func (sb *streamBuffer) Write(f Frame) error {
|
||||||
if f.Closing == 1 {
|
if f.Closing == 1 {
|
||||||
// empty data indicates closing signal
|
// empty data indicates closing signal
|
||||||
sb.buf.Close()
|
sb.buf.Close()
|
||||||
return ClosingFrameReceived
|
return nil
|
||||||
} else {
|
} else {
|
||||||
sb.buf.Write(f.Payload)
|
sb.buf.Write(f.Payload)
|
||||||
sb.nextRecvSeq += 1
|
sb.nextRecvSeq += 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue