Skip to content

Commit

Permalink
Closed Http1x connections must be removed from the client connection …
Browse files Browse the repository at this point in the history
…map when the connection becomes inactive
  • Loading branch information
vietj committed Jul 1, 2017
1 parent 0ba8b3b commit d48f783
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/vertx/core/http/impl/Http1xPool.java
Expand Up @@ -168,6 +168,7 @@ void createConn(HttpVersion version, ContextImpl context, int port, String host,
// gets the closed on, they will check if it's closed and if so get another one.
private synchronized void connectionClosed(ClientConnection conn) {
synchronized (queue) {
connectionMap.remove(conn.channel());
allConnections.remove(conn);
availableConnections.remove(conn);
queue.connectionClosed();
Expand Down
15 changes: 3 additions & 12 deletions src/main/java/io/vertx/core/http/impl/Http2ConnectionBase.java
Expand Up @@ -78,8 +78,7 @@ static ByteBuf safeBuffer(ByteBuf buf, ByteBufAllocator allocator) {
}

protected final IntObjectMap<VertxHttp2Stream> streams = new IntObjectHashMap<>();
protected ChannelHandlerContext handlerContext;
protected final Channel channel;
protected final ChannelHandlerContext handlerContext;
protected final VertxHttp2ConnectionHandler handler;
private boolean shutdown;
private Handler<io.vertx.core.http.Http2Settings> clientSettingsHandler;
Expand All @@ -94,9 +93,8 @@ static ByteBuf safeBuffer(ByteBuf buf, ByteBufAllocator allocator) {

public Http2ConnectionBase(ContextImpl context, VertxHttp2ConnectionHandler handler) {
super(context.owner(), handler.context(), context);
this.channel = handler.context().channel();
this.handlerContext = channel.pipeline().context(handler);
this.handler = handler;
this.handlerContext = chctx;
this.windowSize = handler.connection().local().flowController().windowSize(handler.connection().connectionStream());
}

Expand Down Expand Up @@ -337,7 +335,7 @@ public synchronized HttpConnection shutdown(long timeout) {
throw new IllegalArgumentException("Invalid timeout value " + timeout);
}
handler.gracefulShutdownTimeoutMillis(timeout);
channel.close();
channel().close();
return this;
}

Expand Down Expand Up @@ -449,13 +447,6 @@ public synchronized Http2ConnectionBase exceptionHandler(Handler<Throwable> hand
return (Http2ConnectionBase) super.exceptionHandler(handler);
}

/**
* @return the Netty channel - for internal usage only
*/
public Channel channel() {
return channel;
}

// Private

private void checkShutdownHandler() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/io/vertx/core/net/impl/ConnectionBase.java
Expand Up @@ -179,6 +179,12 @@ protected void checkContext() {
}
}

/**
* @return the Netty channel - for internal usage only
*/
public Channel channel() {
return chctx.channel();
}

public ContextImpl getContext() {
return context;
Expand Down

0 comments on commit d48f783

Please sign in to comment.