@@ -290,8 +290,8 @@ protected void processStreamOnContainerThread(Stream stream) {
290
290
}
291
291
292
292
293
- protected void decrementActiveRemoteStreamCount () {
294
- setConnectionTimeoutForStreamCount (activeRemoteStreamCount . decrementAndGet ());
293
+ protected void decrementActiveRemoteStreamCount (Stream stream ) {
294
+ setConnectionTimeoutForStreamCount (stream . decrementAndGetActiveRemoteStreamCount ());
295
295
}
296
296
297
297
@@ -598,7 +598,7 @@ void sendStreamReset(StreamStateMachine state, StreamException se) throws IOExce
598
598
boolean active = state .isActive ();
599
599
state .sendReset ();
600
600
if (active ) {
601
- decrementActiveRemoteStreamCount ();
601
+ decrementActiveRemoteStreamCount (getStream ( se . getStreamId ()) );
602
602
}
603
603
}
604
604
socketWrapper .write (true , rstFrame , 0 , rstFrame .length );
@@ -825,7 +825,7 @@ void writeBody(Stream stream, ByteBuffer data, int len, boolean finished) throws
825
825
protected void sentEndOfStream (Stream stream ) {
826
826
stream .sentEndOfStream ();
827
827
if (!stream .isActive ()) {
828
- decrementActiveRemoteStreamCount ();
828
+ decrementActiveRemoteStreamCount (stream );
829
829
}
830
830
}
831
831
@@ -1208,7 +1208,7 @@ private int allocate(AbstractStream stream, int allocation) {
1208
1208
}
1209
1209
1210
1210
1211
- private Stream getStream (int streamId ) {
1211
+ Stream getStream (int streamId ) {
1212
1212
Integer key = Integer .valueOf (streamId );
1213
1213
AbstractStream result = streams .get (key );
1214
1214
if (result instanceof Stream ) {
@@ -1536,6 +1536,7 @@ public HeaderEmitter headersStart(int streamId, boolean headersEndStream) throws
1536
1536
Stream stream = getStream (streamId , false );
1537
1537
if (stream == null ) {
1538
1538
stream = createRemoteStream (streamId );
1539
+ activeRemoteStreamCount .incrementAndGet ();
1539
1540
}
1540
1541
if (streamId < maxActiveRemoteStreamId ) {
1541
1542
throw new ConnectionException (sm .getString ("upgradeHandler.stream.old" , Integer .valueOf (streamId ),
@@ -1597,9 +1598,8 @@ public void headersEnd(int streamId, boolean endOfStream) throws Http2Exception
1597
1598
Stream stream = (Stream ) abstractNonZeroStream ;
1598
1599
if (stream .isActive ()) {
1599
1600
if (stream .receivedEndOfHeaders ()) {
1600
-
1601
- if (localSettings .getMaxConcurrentStreams () < activeRemoteStreamCount .incrementAndGet ()) {
1602
- decrementActiveRemoteStreamCount ();
1601
+ if (localSettings .getMaxConcurrentStreams () < activeRemoteStreamCount .get ()) {
1602
+ decrementActiveRemoteStreamCount (stream );
1603
1603
// Ignoring maxConcurrentStreams increases the overhead count
1604
1604
increaseOverheadCount (FrameType .HEADERS );
1605
1605
throw new StreamException (
@@ -1643,7 +1643,7 @@ public void receivedEndOfStream(int streamId) throws ConnectionException {
1643
1643
private void receivedEndOfStream (Stream stream ) throws ConnectionException {
1644
1644
stream .receivedEndOfStream ();
1645
1645
if (!stream .isActive ()) {
1646
- decrementActiveRemoteStreamCount ();
1646
+ decrementActiveRemoteStreamCount (stream );
1647
1647
}
1648
1648
}
1649
1649
@@ -1669,7 +1669,7 @@ public void reset(int streamId, long errorCode) throws Http2Exception {
1669
1669
boolean active = stream .isActive ();
1670
1670
stream .receiveReset (errorCode );
1671
1671
if (active ) {
1672
- decrementActiveRemoteStreamCount ();
1672
+ decrementActiveRemoteStreamCount (stream );
1673
1673
}
1674
1674
}
1675
1675
}
0 commit comments