@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { promise = promise.unvoid(); // Avoid NotYetConnectedException if (!ctx.channel().isActive()) { ctx.close(promise); return; } // If the user has already sent a GO_AWAY frame they may be attempting to do a graceful shutdown which requires // sending multiple GO_AWAY frames. We should only send a GO_AWAY here if one has not already been sent. If // a GO_AWAY has been sent we send a empty buffer just so we can wait to close until all other data has been // flushed to the OS. // https://github.com/netty/netty/issues/5307 final ChannelFuture future = connection().goAwaySent() ? ctx.write(EMPTY_BUFFER) : goAway(ctx, null); ctx.flush(); doGracefulShutdown(ctx, future, promise); }
private void checkShutdownHandler() { Handler<Void> shutdownHandler; synchronized (this) { if (shutdown) { return; } Http2Connection conn = handler.connection(); if ((!conn.goAwayReceived() && !conn.goAwaySent()) || conn.numActiveStreams() > 0) { return; } shutdown = true; shutdownHandler = this.shutdownHandler; } if (shutdownHandler != null) { context.executeFromIO(shutdownHandler); } } }
/** * Helper method for determining whether or not to ignore inbound frames. A stream is considered to be created * after a {@code GOAWAY} is sent if the following conditions hold: * <p/> * <ul> * <li>A {@code GOAWAY} must have been sent by the local endpoint</li> * <li>The {@code streamId} must identify a legitimate stream id for the remote endpoint to be creating</li> * <li>{@code streamId} is greater than the Last Known Stream ID which was sent by the local endpoint * in the last {@code GOAWAY} frame</li> * </ul> * <p/> */ private boolean streamCreatedAfterGoAwaySent(int streamId) { Endpoint<?> remote = connection.remote(); return connection.goAwaySent() && remote.isValidStreamId(streamId) && streamId > remote.lastStreamKnownByPeer(); }
final Http2Connection connection = connection(); try { if (!connection.goAwaySent(lastStreamId, errorCode, debugData)) { debugData.release(); promise.trySuccess();
private void checkShutdownHandler() { Handler<Void> shutdownHandler; synchronized (this) { if (shutdown) { return; } Http2Connection conn = handler.connection(); if ((!conn.goAwayReceived() && !conn.goAwaySent()) || conn.numActiveStreams() > 0) { return; } shutdown = true; shutdownHandler = this.shutdownHandler; } if (shutdownHandler != null) { context.executeFromIO(shutdownHandler); } } }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { promise = promise.unvoid(); // Avoid NotYetConnectedException if (!ctx.channel().isActive()) { ctx.close(promise); return; } // If the user has already sent a GO_AWAY frame they may be attempting to do a graceful shutdown which requires // sending multiple GO_AWAY frames. We should only send a GO_AWAY here if one has not already been sent. If // a GO_AWAY has been sent we send a empty buffer just so we can wait to close until all other data has been // flushed to the OS. // https://github.com/netty/netty/issues/5307 final ChannelFuture future = connection().goAwaySent() ? ctx.write(EMPTY_BUFFER) : goAway(ctx, null); ctx.flush(); doGracefulShutdown(ctx, future, promise); }
@Override public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { promise = promise.unvoid(); // Avoid NotYetConnectedException if (!ctx.channel().isActive()) { ctx.close(promise); return; } // If the user has already sent a GO_AWAY frame they may be attempting to do a graceful shutdown which requires // sending multiple GO_AWAY frames. We should only send a GO_AWAY here if one has not already been sent. If // a GO_AWAY has been sent we send a empty buffer just so we can wait to close until all other data has been // flushed to the OS. // https://github.com/netty/netty/issues/5307 final ChannelFuture future = connection().goAwaySent() ? ctx.write(EMPTY_BUFFER) : goAway(ctx, null); ctx.flush(); doGracefulShutdown(ctx, future, promise); }
/** * Helper method for determining whether or not to ignore inbound frames. A stream is considered to be created * after a {@code GOAWAY} is sent if the following conditions hold: * <p/> * <ul> * <li>A {@code GOAWAY} must have been sent by the local endpoint</li> * <li>The {@code streamId} must identify a legitimate stream id for the remote endpoint to be creating</li> * <li>{@code streamId} is greater than the Last Known Stream ID which was sent by the local endpoint * in the last {@code GOAWAY} frame</li> * </ul> * <p/> */ private boolean streamCreatedAfterGoAwaySent(int streamId) { Endpoint<?> remote = connection.remote(); return connection.goAwaySent() && remote.isValidStreamId(streamId) && streamId > remote.lastStreamKnownByPeer(); }
/** * Helper method for determining whether or not to ignore inbound frames. A stream is considered to be created * after a {@code GOAWAY} is sent if the following conditions hold: * <p/> * <ul> * <li>A {@code GOAWAY} must have been sent by the local endpoint</li> * <li>The {@code streamId} must identify a legitimate stream id for the remote endpoint to be creating</li> * <li>{@code streamId} is greater than the Last Known Stream ID which was sent by the local endpoint * in the last {@code GOAWAY} frame</li> * </ul> * <p/> */ private boolean streamCreatedAfterGoAwaySent(int streamId) { Endpoint<?> remote = connection.remote(); return connection.goAwaySent() && remote.isValidStreamId(streamId) && streamId > remote.lastStreamKnownByPeer(); }
/** * Helper method for determining whether or not to ignore inbound frames. A stream is considered to be created * after a {@code GOAWAY} is sent if the following conditions hold: * <p/> * <ul> * <li>A {@code GOAWAY} must have been sent by the local endpoint</li> * <li>The {@code streamId} must identify a legitimate stream id for the remote endpoint to be creating</li> * <li>{@code streamId} is greater than the Last Known Stream ID which was sent by the local endpoint * in the last {@code GOAWAY} frame</li> * </ul> * <p/> */ private boolean streamCreatedAfterGoAwaySent(int streamId) { Endpoint<?> remote = connection.remote(); return connection.goAwaySent() && remote.isValidStreamId(streamId) && streamId > remote.lastStreamKnownByPeer(); }
/** * Helper method for determining whether or not to ignore inbound frames. A stream is considered to be created * after a {@code GOAWAY} is sent if the following conditions hold: * <p/> * <ul> * <li>A {@code GOAWAY} must have been sent by the local endpoint</li> * <li>The {@code streamId} must identify a legitimate stream id for the remote endpoint to be creating</li> * <li>{@code streamId} is greater than the Last Known Stream ID which was sent by the local endpoint * in the last {@code GOAWAY} frame</li> * </ul> * <p/> */ private boolean streamCreatedAfterGoAwaySent(int streamId) { Endpoint<?> remote = connection.remote(); return connection.goAwaySent() && remote.isValidStreamId(streamId) && streamId > remote.lastStreamKnownByPeer(); }
final Http2Connection connection = connection(); try { if (!connection.goAwaySent(lastStreamId, errorCode, debugData)) { debugData.release(); promise.trySuccess();
promise = promise.unvoid(); final Http2Connection connection = connection(); if (connection().goAwaySent()) { connection.goAwaySent(lastStreamId, errorCode, debugData);