netty/patches/13778.patch

37 lines
1.6 KiB
Diff
Raw Normal View History

2024-01-22 08:39:20 +01:00
From 88de2875dd8c75c1921c2bbb22775d2cb1432396 Mon Sep 17 00:00:00 2001
From: Norman Maurer <norman_maurer@apple.com>
Date: Thu, 11 Jan 2024 17:50:40 +0100
Subject: [PATCH] DnsNameResolver: Limit connect timeout to query timeout
Motivation:
We should not use the default connect timeout (10s) but better use the query timeout as the limit
Modifications:
Use query timeout as connect timeout if any is configured
Result:
Faster failing connect timeouts when using TCP fallback
---
.../src/main/java/io/netty/resolver/dns/DnsNameResolver.java | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java
index 535b87cee39f..6fbf86fc29d9 100644
--- a/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java
+++ b/resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java
@@ -466,6 +466,11 @@ public DnsNameResolver(
.channelFactory(socketChannelFactory)
.attr(DNS_PIPELINE_ATTRIBUTE, Boolean.TRUE)
.handler(TCP_ENCODER);
+ if (queryTimeoutMillis > 0 && queryTimeoutMillis <= Integer.MAX_VALUE) {
+ // Set the connect timeout to the same as queryTimeout as otherwise it might take a long
+ // time for the query to fail in case of a connection timeout.
+ socketBootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, (int) queryTimeoutMillis);
+ }
}
switch (this.resolvedAddressTypes) {
case IPV4_ONLY: