Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set specific keepalive options by default on supported platforms #59278

Merged
merged 18 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Naming
  • Loading branch information
ywelsch committed Jul 27, 2020
commit 1dbe2391e6135ab28686fca959569b227631afe5
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static <T> SocketOption<T> getExtendedSocketOptionOrNull(String fieldNam
* Such a high value can result in firewalls eagerly closing these connections. To tell any intermediate devices that
* the connection remains alive, we explicitly set these options to 5 minutes if the defaults are higher than that.
*/
public static void setSaneDefaultKeepAliveOptions(NetworkChannel socketChannel) {
public static void tryEnsureReasonableKeepAliveConfig(NetworkChannel socketChannel) {
assert socketChannel != null;
try {
if (socketChannel.supportedOptions().contains(StandardSocketOptions.SO_KEEPALIVE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private void configureSocket(Socket socket, boolean isConnectComplete) throws IO
}
}
}
NetUtils.setSaneDefaultKeepAliveOptions(socket.getChannel());
NetUtils.tryEnsureReasonableKeepAliveConfig(socket.getChannel());
socket.setTcpNoDelay(socketConfig.tcpNoDelay());
int tcpSendBufferSize = socketConfig.tcpSendBufferSize();
if (tcpSendBufferSize > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected void initChannel(Channel ch) throws Exception {
addClosedExceptionLogger(ch);
assert ch instanceof Netty4NioSocketChannel;
if (ch instanceof Netty4NioSocketChannel) {
NetUtils.setSaneDefaultKeepAliveOptions(((Netty4NioSocketChannel) ch).javaChannel());
NetUtils.tryEnsureReasonableKeepAliveConfig(((Netty4NioSocketChannel) ch).javaChannel());
}
ch.pipeline().addLast("logging", new ESLoggingHandler());
// using a dot as a prefix means this cannot come from any settings parsed
Expand All @@ -337,7 +337,7 @@ protected void initChannel(Channel ch) throws Exception {
addClosedExceptionLogger(ch);
assert ch instanceof Netty4NioSocketChannel;
if (ch instanceof Netty4NioSocketChannel) {
NetUtils.setSaneDefaultKeepAliveOptions(((Netty4NioSocketChannel) ch).javaChannel());
NetUtils.tryEnsureReasonableKeepAliveConfig(((Netty4NioSocketChannel) ch).javaChannel());
}
Netty4TcpChannel nettyTcpChannel = new Netty4TcpChannel(ch, true, name, ch.newSucceededFuture());
ch.attr(CHANNEL_KEY).set(nettyTcpChannel);
Expand Down