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() defer sesh.streamsM.Unlock()
stream, existing := sesh.streams[frame.StreamID] stream, existing := sesh.streams[frame.StreamID]
if existing { if existing {
stream.writeFrame(*frame) return stream.writeFrame(*frame)
return nil
} else { } else {
if frame.Closing == 1 { if frame.Closing == 1 {
// If the stream has been closed and the current frame is a closing frame, we do noop // 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 // we ignore the error here. If the switchboard is broken, it will be reflected upon stream.Write
stream = makeStream(sesh, frame.StreamID, connId) stream = makeStream(sesh, frame.StreamID, connId)
sesh.acceptCh <- stream sesh.acceptCh <- stream
stream.writeFrame(*frame) return stream.writeFrame(*frame)
return nil
} }
} }

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) isClosed() bool { return atomic.LoadUint32(&s.closed) == 1 }
func (s *Stream) writeFrame(frame Frame) { func (s *Stream) writeFrame(frame Frame) error {
// TODO: Return error return s.recvBuf.Write(frame)
s.recvBuf.Write(frame)
} }
// Read implements io.Read // Read implements io.Read