Skip to content

Commit

Permalink
Fixed stream.fc being nil
Browse files Browse the repository at this point in the history
  • Loading branch information
zasweq committed Jul 11, 2022
1 parent 4459a50 commit 6980fa7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,6 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
cleanup(err)
return err
}
s.fc = &inFlow{limit: uint32(t.initialWindowSize)}
t.activeStreams[id] = s
if channelz.IsOn() {
atomic.AddInt64(&t.czData.streamsStarted, 1)
atomic.StoreInt64(&t.czData.lastStreamCreatedTime, time.Now().UnixNano())
Expand Down Expand Up @@ -719,6 +717,10 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
h.streamID = t.nextID
t.nextID += 2
s.id = h.streamID
s.fc = &inFlow{limit: uint32(t.initialWindowSize)}
t.mu.Lock()
t.activeStreams[s.id] = s
t.mu.Unlock()
if t.streamQuota > 0 && t.waitingStreams > 0 {
select {
case t.streamsQuotaAvailable <- struct{}{}:
Expand All @@ -744,10 +746,10 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
}
for {
success, err := t.controlBuf.executeAndPut(func(it interface{}) bool {
if !checkForStreamQuota(it) {
if !checkForHeaderListSize(it) {
return false
}
if !checkForHeaderListSize(it) {
if !checkForStreamQuota(it) {
return false
}
return true
Expand Down

0 comments on commit 6980fa7

Please sign in to comment.