From 27afe136d4ef1cf700802cc4d719156f0445f2b4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 29 May 2017 03:13:56 +0100 Subject: mono is a total crap --- OpenSim/Framework/Util.cs | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e3d89dc..3ddeafb 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1064,6 +1064,9 @@ namespace OpenSim.Framework public static IPEndPoint getEndPoint(string hostname, int port) { + if(String.IsNullOrWhiteSpace(hostname)) + return null; + IPAddress ia = null; // If it is already an IP, avoid possible broken mono from seeing it if (IPAddress.TryParse(hostname, out ia) && ia != null) @@ -1075,31 +1078,31 @@ namespace OpenSim.Framework // Reset for next check ia = null; - try +#if (_MONO) + // mono is a TOTAL CRAP + int retry = 3; + while(ia == null && retry-- >= 0) +#endif { - foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) + try { - if (ia == null) - ia = Adr; - - if (Adr.AddressFamily == AddressFamily.InterNetwork) + foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) { - ia = Adr; - break; + if (ia == null) + ia = Adr; + + if (Adr.AddressFamily == AddressFamily.InterNetwork) + { + ia = Adr; + break; + } } } + catch // (SocketException e) + { + ia = null; + } } - catch // (SocketException e) - { - /*throw new Exception( - "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + - e + "' attached to this exception", e);*/ - // Don't throw a fatal exception here, instead, return Null and handle it in the caller. - // Reason is, on systems such as OSgrid it has occured that known hostnames stop - // resolving and thus make surrounding regions crash out with this exception. - return null; - } - return getEndPoint(ia,port); } -- cgit v1.1