writeFrame returns error

This commit is contained in:
Andy Wang 2019-08-30 20:43:04 +01:00
parent a131af3439
commit 3f532ae065
2 changed files with 4 additions and 7 deletions

View File

@ -151,8 +151,7 @@ func (sesh *Session) recvDataFromRemote(data []byte) error {
defer sesh.streamsM.Unlock()
stream, existing := sesh.streams[frame.StreamID]
if existing {
stream.writeFrame(*frame)
return nil
return stream.writeFrame(*frame)
} else {
if frame.Closing == 1 {
// If the stream has been closed and the current frame is a closing frame, we do noop
@ -166,8 +165,7 @@ func (sesh *Session) recvDataFromRemote(data []byte) error {
// we ignore the error here. If the switchboard is broken, it will be reflected upon stream.Write
stream = makeStream(sesh, frame.StreamID, connId)
sesh.acceptCh <- stream
stream.writeFrame(*frame)
return nil
return stream.writeFrame(*frame)
}
}

View File

@ -60,9 +60,8 @@ func makeStream(sesh *Session, id uint32, assignedConnId uint32) *Stream {
func (s *Stream) isClosed() bool { return atomic.LoadUint32(&s.closed) == 1 }
func (s *Stream) writeFrame(frame Frame) {
// TODO: Return error
s.recvBuf.Write(frame)
func (s *Stream) writeFrame(frame Frame) error {
return s.recvBuf.Write(frame)
}
// Read implements io.Read