netty: fix transport spuriously in notInUse state

Previously, if two streams are added (but not active yet), then the transport is changed into inUse; after that, if one of them gets active and then closed and removed, then the transport will be changed into and staying at notInUse, although the other stream could later be active.
This commit is contained in:
ZHANG Dapeng 2017-08-23 13:38:05 -07:00 committed by GitHub
parent dafea0100a
commit fe1583c9b4
1 changed files with 14 additions and 16 deletions

View File

@ -184,30 +184,28 @@ class NettyClientHandler extends AbstractNettyHandler {
}
}
@Override
public void onStreamAdded(Http2Stream stream) {
NettyClientHandler.this.lifecycleManager.notifyInUse(true);
}
@Override
public void onStreamRemoved(Http2Stream stream) {
if (connection().numActiveStreams() == 0) {
NettyClientHandler.this.lifecycleManager.notifyInUse(false);
}
}
@Override
public void onStreamActive(Http2Stream stream) {
if (NettyClientHandler.this.keepAliveManager != null
&& connection().numActiveStreams() == 1) {
if (connection().numActiveStreams() != 1) {
return;
}
NettyClientHandler.this.lifecycleManager.notifyInUse(true);
if (NettyClientHandler.this.keepAliveManager != null) {
NettyClientHandler.this.keepAliveManager.onTransportActive();
}
}
@Override
public void onStreamClosed(Http2Stream stream) {
if (NettyClientHandler.this.keepAliveManager != null
&& connection().numActiveStreams() == 0) {
if (connection().numActiveStreams() != 0) {
return;
}
NettyClientHandler.this.lifecycleManager.notifyInUse(false);
if (NettyClientHandler.this.keepAliveManager != null) {
NettyClientHandler.this.keepAliveManager.onTransportIdle();
}
}