@@ -439,10 +439,6 @@ public final void onInput(final ByteBuffer src) throws HttpException, IOExceptio
439439 for (;;) {
440440 final RawFrame frame = inputBuffer .read (src , ioSession );
441441 if (frame != null ) {
442- if (connState .compareTo (ConnectionHandshake .SHUTDOWN ) < 0 ) {
443- checkStreamTimeouts (System .nanoTime ());
444- }
445-
446442 if (streamListener != null ) {
447443 streamListener .onFrameInput (this , frame .getStreamId (), frame );
448444 }
@@ -655,7 +651,6 @@ private void executeRequest(final RequestExecutionCommand requestExecutionComman
655651 requestExecutionCommand .getExchangeHandler (),
656652 requestExecutionCommand .getPushHandlerFactory (),
657653 requestExecutionCommand .getContext ()));
658- initializeStreamTimeouts (stream );
659654
660655 if (streamListener != null ) {
661656 final int initInputWindow = stream .getInputWindow ().get ();
@@ -774,12 +769,10 @@ private void consumeFrame(final RawFrame frame) throws HttpException, IOExceptio
774769 final H2StreamChannel channel = createChannel (streamId );
775770 if (connState .compareTo (ConnectionHandshake .ACTIVE ) <= 0 ) {
776771 stream = streams .createActive (channel , incomingRequest (channel ));
777- initializeStreamTimeouts (stream );
778772 streams .resetIfExceedsMaxConcurrentLimit (stream , localConfig .getMaxConcurrentStreams ());
779773 } else {
780774 channel .localReset (H2Error .REFUSED_STREAM );
781775 stream = streams .createActive (channel , NoopH2StreamHandler .INSTANCE );
782- initializeStreamTimeouts (stream );
783776 }
784777 } else if (stream .isLocalClosed () && stream .isRemoteClosed ()) {
785778 throw new H2ConnectionException (H2Error .STREAM_CLOSED , "Stream closed" );
@@ -970,7 +963,6 @@ private void consumeFrame(final RawFrame frame) throws HttpException, IOExceptio
970963 channel .localReset (H2Error .REFUSED_STREAM );
971964 promisedStream = streams .createActive (channel , NoopH2StreamHandler .INSTANCE );
972965 }
973- initializeStreamTimeouts (promisedStream );
974966 try {
975967 consumePushPromiseFrame (frame , payload , promisedStream );
976968 } catch (final H2StreamResetException ex ) {
@@ -1376,16 +1368,8 @@ H2StreamChannel createChannel(final int streamId) {
13761368 return new H2StreamChannelImpl (streamId , initInputWinSize , initOutputWinSize );
13771369 }
13781370
1379- private void initializeStreamTimeouts (final H2Stream stream ) {
1380- final Timeout socketTimeout = ioSession .getSocketTimeout ();
1381- if (socketTimeout != null && socketTimeout .isEnabled ()) {
1382- stream .setIdleTimeout (socketTimeout );
1383- }
1384- }
1385-
13861371 H2Stream createStream (final H2StreamChannel channel , final H2StreamHandler streamHandler ) {
13871372 final H2Stream stream = streams .createActive (channel , streamHandler );
1388- initializeStreamTimeouts (stream );
13891373 return stream ;
13901374 }
13911375
@@ -1489,7 +1473,6 @@ public void push(final List<Header> headers, final AsyncPushProducer pushProduce
14891473 final int promisedStreamId = streams .generateStreamId ();
14901474 final H2StreamChannel channel = createChannel (promisedStreamId );
14911475 final H2Stream stream = streams .createReserved (channel , outgoingPushPromise (channel , pushProducer ));
1492- initializeStreamTimeouts (stream );
14931476
14941477 commitPushPromise (id , promisedStreamId , headers );
14951478 stream .markRemoteClosed ();
@@ -1614,43 +1597,21 @@ private void checkStreamTimeouts(final long nowNanos) throws IOException {
16141597 }
16151598
16161599 final Timeout idleTimeout = stream .getIdleTimeout ();
1617- final Timeout lifetimeTimeout = stream .getLifetimeTimeout ();
1618- if ((idleTimeout == null || !idleTimeout .isEnabled ())
1619- && (lifetimeTimeout == null || !lifetimeTimeout .isEnabled ())) {
1600+ if (idleTimeout == null || !idleTimeout .isEnabled ()) {
16201601 continue ;
16211602 }
16221603
1623- final long created = stream .getCreatedNanos ();
16241604 final long last = stream .getLastActivityNanos ();
1625-
1626- if (idleTimeout != null && idleTimeout .isEnabled ()) {
1627- final long idleNanos = idleTimeout .toNanoseconds ();
1628- if (idleNanos > 0 && nowNanos - last > idleNanos ) {
1629- final int streamId = stream .getId ();
1630- final H2StreamTimeoutException ex = new H2StreamTimeoutException (
1631- "HTTP/2 stream idle timeout (" + idleTimeout + ")" ,
1632- streamId ,
1633- idleTimeout ,
1634- true );
1635- stream .localReset (ex , H2Error .CANCEL );
1636- // Once reset due to idle timeout, we do not care about lifetime anymore
1637- continue ;
1638- }
1639- }
1640-
1641- if (lifetimeTimeout != null && lifetimeTimeout .isEnabled ()) {
1642- final long lifeNanos = lifetimeTimeout .toNanoseconds ();
1643- if (lifeNanos > 0 && nowNanos - created > lifeNanos ) {
1644- final int streamId = stream .getId ();
1645- final H2StreamTimeoutException ex = new H2StreamTimeoutException (
1646- "HTTP/2 stream lifetime timeout (" + lifetimeTimeout + ")" ,
1647- streamId ,
1648- lifetimeTimeout ,
1649- false );
1650- stream .localReset (ex , H2Error .CANCEL );
1651- }
1605+ final long idleNanos = idleTimeout .toNanoseconds ();
1606+ if (idleNanos > 0 && nowNanos - last > idleNanos ) {
1607+ final int streamId = stream .getId ();
1608+ final H2StreamTimeoutException ex = new H2StreamTimeoutException (
1609+ "HTTP/2 stream idle timeout (" + idleTimeout + ")" ,
1610+ streamId ,
1611+ idleTimeout ,
1612+ true );
1613+ stream .localReset (ex , H2Error .CANCEL );
16521614 }
16531615 }
16541616 }
1655-
16561617}
0 commit comments