Skip to content

Commit

Permalink
transport: make http2Client.getStream() to only return a stream. (#2984)
Browse files Browse the repository at this point in the history
Suggested in #2980.
  • Loading branch information
easwars authored Aug 16, 2019
1 parent 0308245 commit c26cd97
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -853,11 +853,11 @@ func (t *http2Client) Write(s *Stream, hdr []byte, data []byte, opts *Options) e
return t.controlBuf.put(df)
}

func (t *http2Client) getStream(f http2.Frame) (*Stream, bool) {
func (t *http2Client) getStream(f http2.Frame) *Stream {
t.mu.Lock()
s, ok := t.activeStreams[f.Header().StreamID]
s := t.activeStreams[f.Header().StreamID]
t.mu.Unlock()
return s, ok
return s
}

// adjustWindow sends out extra window update over the initial window size
Expand Down Expand Up @@ -937,8 +937,8 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
t.controlBuf.put(bdpPing)
}
// Select the right stream to dispatch.
s, ok := t.getStream(f)
if !ok {
s := t.getStream(f)
if s == nil {
return
}
if size > 0 {
Expand Down Expand Up @@ -969,8 +969,8 @@ func (t *http2Client) handleData(f *http2.DataFrame) {
}

func (t *http2Client) handleRSTStream(f *http2.RSTStreamFrame) {
s, ok := t.getStream(f)
if !ok {
s := t.getStream(f)
if s == nil {
return
}
if f.ErrCode == http2.ErrCodeRefusedStream {
Expand Down Expand Up @@ -1147,8 +1147,8 @@ func (t *http2Client) handleWindowUpdate(f *http2.WindowUpdateFrame) {

// operateHeaders takes action on the decoded headers.
func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
s, ok := t.getStream(frame)
if !ok {
s := t.getStream(frame)
if s == nil {
return
}
endStream := frame.StreamEnded()
Expand Down

0 comments on commit c26cd97

Please sign in to comment.