From c9b7ec2af91792b9d6558875c2a44267ac0ac5a0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 9 Aug 2019 12:06:33 +0100 Subject: [PATCH] Make the DNS cache timeout configurable. In containerized environments, DNS is simulated. It can change several times per second as containers move around. The hardcoded timeout was too long for a container environment. --- OpenSim/Region/Application/Application.cs | 2 +- OpenSim/Region/Application/OpenSim.cs | 4 ++++ OpenSim/Server/ServerMain.cs | 5 +++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index e4c3329740..7c3b6c5029 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs @@ -84,7 +84,7 @@ namespace OpenSim ServicePointManager.DefaultConnectionLimit = 12; } - try { ServicePointManager.DnsRefreshTimeout = 300000; } catch { } + try { ServicePointManager.DnsRefreshTimeout = 5000; } catch { } ServicePointManager.Expect100Continue = false; ServicePointManager.UseNagleAlgorithm = false; diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index fcc87177a6..ee4ddf4ba8 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -37,6 +37,7 @@ using System.Runtime; using System.Text; using System.Text.RegularExpressions; using System.Timers; +using System.Net; using log4net; using NDesk.Options; using Nini.Config; @@ -119,6 +120,9 @@ namespace OpenSim stpMinThreads = startupConfig.GetInt("MinPoolThreads", 2 ); stpMaxThreads = startupConfig.GetInt("MaxPoolThreads", 25); m_consolePrompt = startupConfig.GetString("ConsolePrompt", @"Region (\R) "); + + int dnsTimeout = startupConfig.GetInt("DnsTimeout", 30000); + try { ServicePointManager.DnsRefreshTimeout = dnsTimeout; } catch { } } if (Util.FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool) diff --git a/OpenSim/Server/ServerMain.cs b/OpenSim/Server/ServerMain.cs index 09f6920df3..c180ca639a 100644 --- a/OpenSim/Server/ServerMain.cs +++ b/OpenSim/Server/ServerMain.cs @@ -85,8 +85,6 @@ namespace OpenSim.Server ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.ServerCertificateValidationCallback = ValidateServerCertificate; - try { ServicePointManager.DnsRefreshTimeout = 300000; } catch { } - m_Server = new HttpServerBase("R.O.B.U.S.T.", args); string registryLocation; @@ -98,6 +96,9 @@ namespace OpenSim.Server throw new Exception("Configuration error"); } + int dnsTimeout = serverConfig.GetInt("DnsTimeout", 30000); + try { ServicePointManager.DnsRefreshTimeout = dnsTimeout; } catch { } + m_NoVerifyCertChain = serverConfig.GetBoolean("NoVerifyCertChain", m_NoVerifyCertChain); m_NoVerifyCertHostname = serverConfig.GetBoolean("NoVerifyCertHostname", m_NoVerifyCertHostname);