Skip to content

Commit 305f6bd

Browse files
committed
small reorder for more clarity
1 parent 568d864 commit 305f6bd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/transport/http2_client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,13 +808,15 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
808808
t.waitingStreams--
809809
}
810810
t.streamQuota--
811+
811812
t.mu.Lock()
812-
hdr.streamID = t.nextID
813-
t.nextID += 2
814813
if t.state == draining || t.activeStreams == nil { // Can be niled from Close().
815814
t.mu.Unlock()
816815
return false // Don't create a stream if the transport is already closed.
817816
}
817+
818+
hdr.streamID = t.nextID
819+
t.nextID += 2
818820
// Drain client transport if nextID > MaxStreamID which signals gRPC that
819821
// the connection is closed and a new one must be created for subsequent RPCs.
820822
transportDrainRequired = t.nextID > MaxStreamID
@@ -823,6 +825,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
823825
s.fc = &inFlow{limit: uint32(t.initialWindowSize)}
824826
t.activeStreams[s.id] = s
825827
t.mu.Unlock()
828+
826829
if t.streamQuota > 0 && t.waitingStreams > 0 {
827830
select {
828831
case t.streamsQuotaAvailable <- struct{}{}:

0 commit comments

Comments
 (0)