aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Util.cs
diff options
context:
space:
mode:
authorMelanie2009-10-08 08:07:38 +0100
committerMelanie2009-10-08 08:07:38 +0100
commitfe679be9e76190ac0dc8892469787e63a7a48b5c (patch)
tree220ef33da75f09b3e7ef3684c5ed7367e175691e /OpenSim/Framework/Util.cs
parentstore owner_uuid in the region table (diff)
parentOne last attempt at tunning the locking/no locking behaviour. The previous on... (diff)
downloadopensim-SC_OLD-fe679be9e76190ac0dc8892469787e63a7a48b5c.zip
opensim-SC_OLD-fe679be9e76190ac0dc8892469787e63a7a48b5c.tar.gz
opensim-SC_OLD-fe679be9e76190ac0dc8892469787e63a7a48b5c.tar.bz2
opensim-SC_OLD-fe679be9e76190ac0dc8892469787e63a7a48b5c.tar.xz
Merge branch 'htb-throttle'
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r--OpenSim/Framework/Util.cs40
1 files changed, 39 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 0851d26..38729c6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1231,6 +1231,42 @@ namespace OpenSim.Framework
1231 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; 1231 return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri;
1232 } 1232 }
1233 1233
1234 public static byte[] StringToBytes256(string str)
1235 {
1236 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; }
1237 if (str.Length > 254) str = str.Remove(254);
1238 if (!str.EndsWith("\0")) { str += "\0"; }
1239
1240 // Because this is UTF-8 encoding and not ASCII, it's possible we
1241 // might have gotten an oversized array even after the string trim
1242 byte[] data = UTF8.GetBytes(str);
1243 if (data.Length > 256)
1244 {
1245 Array.Resize<byte>(ref data, 256);
1246 data[255] = 0;
1247 }
1248
1249 return data;
1250 }
1251
1252 public static byte[] StringToBytes1024(string str)
1253 {
1254 if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; }
1255 if (str.Length > 1023) str = str.Remove(1023);
1256 if (!str.EndsWith("\0")) { str += "\0"; }
1257
1258 // Because this is UTF-8 encoding and not ASCII, it's possible we
1259 // might have gotten an oversized array even after the string trim
1260 byte[] data = UTF8.GetBytes(str);
1261 if (data.Length > 1024)
1262 {
1263 Array.Resize<byte>(ref data, 1024);
1264 data[1023] = 0;
1265 }
1266
1267 return data;
1268 }
1269
1234 #region FireAndForget Threading Pattern 1270 #region FireAndForget Threading Pattern
1235 1271
1236 public static void FireAndForget(System.Threading.WaitCallback callback) 1272 public static void FireAndForget(System.Threading.WaitCallback callback)
@@ -1247,7 +1283,9 @@ namespace OpenSim.Framework
1247 { 1283 {
1248 System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState; 1284 System.Threading.WaitCallback callback = (System.Threading.WaitCallback)ar.AsyncState;
1249 1285
1250 callback.EndInvoke(ar); 1286 try { callback.EndInvoke(ar); }
1287 catch (Exception ex) { m_log.Error("[UTIL]: Asynchronous method threw an exception: " + ex.Message, ex); }
1288
1251 ar.AsyncWaitHandle.Close(); 1289 ar.AsyncWaitHandle.Close();
1252 } 1290 }
1253 1291