From 6475a5bb3e718d87b0dc05bde99ca5bc7db5ec42 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Mon, 6 Jun 2016 23:36:48 +0200 Subject: [PATCH] fix a race condition in session.handleWindowUpdateFrame --- session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/session.go b/session.go index ec0e9c2f9..559f9aa06 100644 --- a/session.go +++ b/session.go @@ -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 {