make the FlowController thread-safe

This commit is contained in:
Marten Seemann
2016-05-17 23:39:07 +07:00
parent 15e7fe6c73
commit b9e141d277
3 changed files with 27 additions and 7 deletions

View File

@@ -290,20 +290,18 @@ func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error
// return errors.New("Connection level flow control not yet implemented")
return nil
}
s.streamsMutex.RLock()
defer s.streamsMutex.RUnlock()
stream, streamExists := s.streams[frame.StreamID]
if !streamExists {
return errWindowUpdateOnInvalidStream
}
if stream == nil {
return errWindowUpdateOnClosedStream
}
s.streamsMutex.RUnlock()
stream.UpdateSendFlowControlWindow(frame.ByteOffset)
return nil
}