diff options
author | UbitUmarov | 2017-05-29 03:13:56 +0100 |
---|---|---|
committer | UbitUmarov | 2017-05-29 03:13:56 +0100 |
commit | 27afe136d4ef1cf700802cc4d719156f0445f2b4 (patch) | |
tree | 3eab200c46638084f3e121d04d4f37fa01f7ad12 /OpenSim/Framework | |
parent | cleanup util.cs get dns (diff) | |
download | opensim-SC_OLD-27afe136d4ef1cf700802cc4d719156f0445f2b4.zip opensim-SC_OLD-27afe136d4ef1cf700802cc4d719156f0445f2b4.tar.gz opensim-SC_OLD-27afe136d4ef1cf700802cc4d719156f0445f2b4.tar.bz2 opensim-SC_OLD-27afe136d4ef1cf700802cc4d719156f0445f2b4.tar.xz |
mono is a total crap
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/Util.cs | 41 |
1 files changed, 22 insertions, 19 deletions
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 | |||
1064 | 1064 | ||
1065 | public static IPEndPoint getEndPoint(string hostname, int port) | 1065 | public static IPEndPoint getEndPoint(string hostname, int port) |
1066 | { | 1066 | { |
1067 | if(String.IsNullOrWhiteSpace(hostname)) | ||
1068 | return null; | ||
1069 | |||
1067 | IPAddress ia = null; | 1070 | IPAddress ia = null; |
1068 | // If it is already an IP, avoid possible broken mono from seeing it | 1071 | // If it is already an IP, avoid possible broken mono from seeing it |
1069 | if (IPAddress.TryParse(hostname, out ia) && ia != null) | 1072 | if (IPAddress.TryParse(hostname, out ia) && ia != null) |
@@ -1075,31 +1078,31 @@ namespace OpenSim.Framework | |||
1075 | 1078 | ||
1076 | // Reset for next check | 1079 | // Reset for next check |
1077 | ia = null; | 1080 | ia = null; |
1078 | try | 1081 | #if (_MONO) |
1082 | // mono is a TOTAL CRAP | ||
1083 | int retry = 3; | ||
1084 | while(ia == null && retry-- >= 0) | ||
1085 | #endif | ||
1079 | { | 1086 | { |
1080 | foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) | 1087 | try |
1081 | { | 1088 | { |
1082 | if (ia == null) | 1089 | foreach (IPAddress Adr in Dns.GetHostAddresses(hostname)) |
1083 | ia = Adr; | ||
1084 | |||
1085 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1086 | { | 1090 | { |
1087 | ia = Adr; | 1091 | if (ia == null) |
1088 | break; | 1092 | ia = Adr; |
1093 | |||
1094 | if (Adr.AddressFamily == AddressFamily.InterNetwork) | ||
1095 | { | ||
1096 | ia = Adr; | ||
1097 | break; | ||
1098 | } | ||
1089 | } | 1099 | } |
1090 | } | 1100 | } |
1101 | catch // (SocketException e) | ||
1102 | { | ||
1103 | ia = null; | ||
1104 | } | ||
1091 | } | 1105 | } |
1092 | catch // (SocketException e) | ||
1093 | { | ||
1094 | /*throw new Exception( | ||
1095 | "Unable to resolve local hostname " + m_externalHostName + " innerException of type '" + | ||
1096 | e + "' attached to this exception", e);*/ | ||
1097 | // Don't throw a fatal exception here, instead, return Null and handle it in the caller. | ||
1098 | // Reason is, on systems such as OSgrid it has occured that known hostnames stop | ||
1099 | // resolving and thus make surrounding regions crash out with this exception. | ||
1100 | return null; | ||
1101 | } | ||
1102 | |||
1103 | return getEndPoint(ia,port); | 1106 | return getEndPoint(ia,port); |
1104 | } | 1107 | } |
1105 | 1108 | ||