fix a race condition in session.handleWindowUpdateFrame

This commit is contained in:
Lucas Clemente
2016-06-06 23:36:48 +02:00
parent ed43ee7bd7
commit 6475a5bb3e

View File

@@ -336,6 +336,7 @@ func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error
s.streamsMutex.RUnlock()
} else {
s.streamsMutex.RLock()
defer s.streamsMutex.RUnlock()
stream, streamExists := s.streams[frame.StreamID]
if !streamExists {
return errWindowUpdateOnInvalidStream
@@ -343,7 +344,6 @@ func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error
if stream == nil {
return errWindowUpdateOnClosedStream
}
s.streamsMutex.RUnlock()
updated := stream.UpdateSendFlowControlWindow(frame.ByteOffset)
if updated {