aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2017-05-07 04:21:33 +0100
committerUbitUmarov2017-05-07 04:21:33 +0100
commit11f6d28a0631d7bf96eed220dc58ab0824fb8f57 (patch)
treec2c08d0908e332983284299a6739c8bc0c136078
parent merge fix (diff)
parentlet StreamReader be in using statements (diff)
downloadopensim-SC-11f6d28a0631d7bf96eed220dc58ab0824fb8f57.zip
opensim-SC-11f6d28a0631d7bf96eed220dc58ab0824fb8f57.tar.gz
opensim-SC-11f6d28a0631d7bf96eed220dc58ab0824fb8f57.tar.bz2
opensim-SC-11f6d28a0631d7bf96eed220dc58ab0824fb8f57.tar.xz
fix merge
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs2
-rw-r--r--OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs7
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs7
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs5
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs6
-rw-r--r--OpenSim/Data/MySQL/MySQLAssetData.cs47
-rw-r--r--OpenSim/Data/MySQL/MySQLAuthenticationData.cs36
-rw-r--r--OpenSim/Data/MySQL/MySQLEstateData.cs12
-rw-r--r--OpenSim/Data/MySQL/MySQLFSAssetData.cs12
-rw-r--r--OpenSim/Data/MySQL/MySQLFramework.cs9
-rw-r--r--OpenSim/Data/MySQL/MySQLGenericTableHandler.cs12
-rw-r--r--OpenSim/Data/MySQL/MySQLInventoryData.cs14
-rw-r--r--OpenSim/Data/MySQL/MySQLRegionData.cs3
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs255
-rw-r--r--OpenSim/Data/MySQL/MySQLUserProfilesData.cs363
-rw-r--r--OpenSim/Data/MySQL/MySQLXAssetData.cs57
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs1
-rw-r--r--OpenSim/Data/MySQL/Resources/os_groups_Store.migrations2
-rw-r--r--OpenSim/Data/PGSQL/PGSQLXAssetData.cs20
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs29
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs7
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs7
-rw-r--r--OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs3
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs8
-rw-r--r--OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs5
-rw-r--r--OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs7
-rw-r--r--OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs6
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs6
-rw-r--r--OpenSim/Server/Handlers/Map/MapAddServerConnector.cs6
-rw-r--r--OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs21
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs6
-rw-r--r--OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs2
-rw-r--r--OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs339
-rw-r--r--OpenSim/Tests/Permissions/Common.cs9
-rwxr-xr-xbin/CSJ2K.dllbin483328 -> 502784 bytes
45 files changed, 907 insertions, 483 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index 0e3a172..5b76e0a 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -787,7 +787,7 @@ namespace OpenSim.Groups
787 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); 787 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
788 788
789 // Update the founder with new group information. 789 // Update the founder with new group information.
790 SendAgentGroupDataUpdate(remoteClient, false); 790 SendAgentGroupDataUpdate(remoteClient, true);
791 } 791 }
792 else 792 else
793 remoteClient.SendCreateGroupReply(groupID, false, reason); 793 remoteClient.SendCreateGroupReply(groupID, false, reason);
diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
index af00770..51f3ec1 100644
--- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
@@ -115,9 +115,10 @@ namespace OpenSim.Groups
115 protected override byte[] ProcessRequest(string path, Stream requestData, 115 protected override byte[] ProcessRequest(string path, Stream requestData,
116 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 116 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
117 { 117 {
118 StreamReader sr = new StreamReader(requestData); 118 string body;
119 string body = sr.ReadToEnd(); 119 using(StreamReader sr = new StreamReader(requestData))
120 sr.Close(); 120 body = sr.ReadToEnd();
121
121 body = body.Trim(); 122 body = body.Trim();
122 123
123 //m_log.DebugFormat("[XXX]: query String: {0}", body); 124 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 598e7a5..8502bb5 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -91,9 +91,10 @@ namespace OpenSim.Groups
91 protected override byte[] ProcessRequest(string path, Stream requestData, 91 protected override byte[] ProcessRequest(string path, Stream requestData,
92 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 92 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
93 { 93 {
94 StreamReader sr = new StreamReader(requestData); 94 string body;
95 string body = sr.ReadToEnd(); 95 using(StreamReader sr = new StreamReader(requestData))
96 sr.Close(); 96 body = sr.ReadToEnd();
97
97 body = body.Trim(); 98 body = body.Trim();
98 99
99 //m_log.DebugFormat("[XXX]: query String: {0}", body); 100 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index 062a842..e73cf9e 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -362,8 +362,6 @@ namespace OpenSim.Capabilities.Handlers
362 { 362 {
363 // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data 363 // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
364 364
365 imgstream = new MemoryStream();
366
367 // Decode image to System.Drawing.Image 365 // Decode image to System.Drawing.Image
368 if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) 366 if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
369 { 367 {
@@ -404,10 +402,7 @@ namespace OpenSim.Capabilities.Handlers
404 if(managedImage != null) 402 if(managedImage != null)
405 managedImage.Clear(); 403 managedImage.Clear();
406 if (imgstream != null) 404 if (imgstream != null)
407 {
408 imgstream.Close();
409 imgstream.Dispose(); 405 imgstream.Dispose();
410 }
411 } 406 }
412 407
413 return data; 408 return data;
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
index d5df7a2..c339ec5 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureRobustHandler.cs
@@ -368,9 +368,6 @@ namespace OpenSim.Capabilities.Handlers
368 try 368 try
369 { 369 {
370 // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data 370 // Taking our jpeg2000 data, decoding it, then saving it to a byte array with regular data
371
372 imgstream = new MemoryStream();
373
374 // Decode image to System.Drawing.Image 371 // Decode image to System.Drawing.Image
375 if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null) 372 if (OpenJPEG.DecodeToImage(texture.Data, out managedImage, out image) && image != null)
376 { 373 {
@@ -412,10 +409,7 @@ namespace OpenSim.Capabilities.Handlers
412 managedImage.Clear(); 409 managedImage.Clear();
413 410
414 if (imgstream != null) 411 if (imgstream != null)
415 {
416 imgstream.Close();
417 imgstream.Dispose(); 412 imgstream.Dispose();
418 }
419 } 413 }
420 414
421 return data; 415 return data;
diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs
index f16cd91..8569c90 100644
--- a/OpenSim/Data/MySQL/MySQLAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLAssetData.cs
@@ -75,6 +75,7 @@ namespace OpenSim.Data.MySQL
75 dbcon.Open(); 75 dbcon.Open();
76 Migration m = new Migration(dbcon, Assembly, "AssetStore"); 76 Migration m = new Migration(dbcon, Assembly, "AssetStore");
77 m.Update(); 77 m.Update();
78 dbcon.Close();
78 } 79 }
79 } 80 }
80 81
@@ -144,6 +145,7 @@ namespace OpenSim.Data.MySQL
144 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e); 145 string.Format("[ASSETS DB]: MySql failure fetching asset {0}. Exception ", assetID), e);
145 } 146 }
146 } 147 }
148 dbcon.Close();
147 } 149 }
148 150
149 return asset; 151 return asset;
@@ -156,28 +158,27 @@ namespace OpenSim.Data.MySQL
156 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> 158 /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
157 override public bool StoreAsset(AssetBase asset) 159 override public bool StoreAsset(AssetBase asset)
158 { 160 {
159 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 161 string assetName = asset.Name;
162 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME)
160 { 163 {
161 dbcon.Open(); 164 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
162 165 m_log.WarnFormat(
163 string assetName = asset.Name; 166 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
164 if (asset.Name.Length > AssetBase.MAX_ASSET_NAME) 167 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
165 { 168 }
166 assetName = asset.Name.Substring(0, AssetBase.MAX_ASSET_NAME);
167 m_log.WarnFormat(
168 "[ASSET DB]: Name '{0}' for asset {1} truncated from {2} to {3} characters on add",
169 asset.Name, asset.ID, asset.Name.Length, assetName.Length);
170 }
171 169
172 string assetDescription = asset.Description; 170 string assetDescription = asset.Description;
173 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC) 171 if (asset.Description.Length > AssetBase.MAX_ASSET_DESC)
174 { 172 {
175 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC); 173 assetDescription = asset.Description.Substring(0, AssetBase.MAX_ASSET_DESC);
176 m_log.WarnFormat( 174 m_log.WarnFormat(
177 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add", 175 "[ASSET DB]: Description '{0}' for asset {1} truncated from {2} to {3} characters on add",
178 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length); 176 asset.Description, asset.ID, asset.Description.Length, assetDescription.Length);
179 } 177 }
180 178
179 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
180 {
181 dbcon.Open();
181 using (MySqlCommand cmd = 182 using (MySqlCommand cmd =
182 new MySqlCommand( 183 new MySqlCommand(
183 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" + 184 "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, CreatorID, data)" +
@@ -200,15 +201,17 @@ namespace OpenSim.Data.MySQL
200 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); 201 cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags);
201 cmd.Parameters.AddWithValue("?data", asset.Data); 202 cmd.Parameters.AddWithValue("?data", asset.Data);
202 cmd.ExecuteNonQuery(); 203 cmd.ExecuteNonQuery();
204 dbcon.Close();
203 return true; 205 return true;
204 } 206 }
205 catch (Exception e) 207 catch (Exception e)
206 { 208 {
207 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}", 209 m_log.ErrorFormat("[ASSET DB]: MySQL failure creating asset {0} with name \"{1}\". Error: {2}",
208 asset.FullID, asset.Name, e.Message); 210 asset.FullID, asset.Name, e.Message);
211 dbcon.Close();
209 return false; 212 return false;
210 } 213 }
211 } 214 }
212 } 215 }
213 } 216 }
214 217
@@ -238,6 +241,7 @@ namespace OpenSim.Data.MySQL
238 e); 241 e);
239 } 242 }
240 } 243 }
244 dbcon.Close();
241 } 245 }
242 } 246 }
243 247
@@ -270,6 +274,7 @@ namespace OpenSim.Data.MySQL
270 } 274 }
271 } 275 }
272 } 276 }
277 dbcon.Close();
273 } 278 }
274 279
275 bool[] results = new bool[uuids.Length]; 280 bool[] results = new bool[uuids.Length];
@@ -334,6 +339,7 @@ namespace OpenSim.Data.MySQL
334 e); 339 e);
335 } 340 }
336 } 341 }
342 dbcon.Close();
337 } 343 }
338 344
339 return retList; 345 return retList;
@@ -350,6 +356,7 @@ namespace OpenSim.Data.MySQL
350 cmd.Parameters.AddWithValue("?id", id); 356 cmd.Parameters.AddWithValue("?id", id);
351 cmd.ExecuteNonQuery(); 357 cmd.ExecuteNonQuery();
352 } 358 }
359 dbcon.Close();
353 } 360 }
354 361
355 return true; 362 return true;
diff --git a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
index af6be75..fef582e 100644
--- a/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
+++ b/OpenSim/Data/MySQL/MySQLAuthenticationData.cs
@@ -59,6 +59,7 @@ namespace OpenSim.Data.MySQL
59 dbcon.Open(); 59 dbcon.Open();
60 Migration m = new Migration(dbcon, Assembly, "AuthStore"); 60 Migration m = new Migration(dbcon, Assembly, "AuthStore");
61 m.Update(); 61 m.Update();
62 dbcon.Close();
62 } 63 }
63 } 64 }
64 65
@@ -76,27 +77,30 @@ namespace OpenSim.Data.MySQL
76 { 77 {
77 cmd.Parameters.AddWithValue("?principalID", principalID.ToString()); 78 cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
78 79
79 IDataReader result = cmd.ExecuteReader(); 80 using(IDataReader result = cmd.ExecuteReader())
80
81 if (result.Read())
82 { 81 {
83 ret.PrincipalID = principalID; 82 if(result.Read())
83 {
84 ret.PrincipalID = principalID;
84 85
85 CheckColumnNames(result); 86 CheckColumnNames(result);
86 87
87 foreach (string s in m_ColumnNames) 88 foreach(string s in m_ColumnNames)
88 { 89 {
89 if (s == "UUID") 90 if(s == "UUID")
90 continue; 91 continue;
91 92
92 ret.Data[s] = result[s].ToString(); 93 ret.Data[s] = result[s].ToString();
93 } 94 }
94 95
95 return ret; 96 dbcon.Close();
96 } 97 return ret;
97 else 98 }
98 { 99 else
99 return null; 100 {
101 dbcon.Close();
102 return null;
103 }
100 } 104 }
101 } 105 }
102 } 106 }
diff --git a/OpenSim/Data/MySQL/MySQLEstateData.cs b/OpenSim/Data/MySQL/MySQLEstateData.cs
index a5c8d24..eeedf02 100644
--- a/OpenSim/Data/MySQL/MySQLEstateData.cs
+++ b/OpenSim/Data/MySQL/MySQLEstateData.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Data.MySQL
82 82
83 Migration m = new Migration(dbcon, Assembly, "EstateStore"); 83 Migration m = new Migration(dbcon, Assembly, "EstateStore");
84 m.Update(); 84 m.Update();
85 dbcon.Close();
85 86
86 Type t = typeof(EstateSettings); 87 Type t = typeof(EstateSettings);
87 m_Fields = t.GetFields(BindingFlags.NonPublic | 88 m_Fields = t.GetFields(BindingFlags.NonPublic |
@@ -143,7 +144,6 @@ namespace OpenSim.Data.MySQL
143 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 144 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
144 { 145 {
145 dbcon.Open(); 146 dbcon.Open();
146
147 cmd.Connection = dbcon; 147 cmd.Connection = dbcon;
148 148
149 bool found = false; 149 bool found = false;
@@ -171,6 +171,8 @@ namespace OpenSim.Data.MySQL
171 } 171 }
172 } 172 }
173 } 173 }
174 dbcon.Close();
175 cmd.Connection = null;
174 176
175 if (!found && create) 177 if (!found && create)
176 { 178 {
@@ -231,6 +233,7 @@ namespace OpenSim.Data.MySQL
231 233
232 es.Save(); 234 es.Save();
233 } 235 }
236 dbcon.Close();
234 } 237 }
235 } 238 }
236 239
@@ -263,6 +266,7 @@ namespace OpenSim.Data.MySQL
263 266
264 cmd.ExecuteNonQuery(); 267 cmd.ExecuteNonQuery();
265 } 268 }
269 dbcon.Close();
266 } 270 }
267 271
268 SaveBanList(es); 272 SaveBanList(es);
@@ -300,6 +304,7 @@ namespace OpenSim.Data.MySQL
300 } 304 }
301 } 305 }
302 } 306 }
307 dbcon.Close();
303 } 308 }
304 } 309 }
305 310
@@ -329,6 +334,7 @@ namespace OpenSim.Data.MySQL
329 cmd.Parameters.Clear(); 334 cmd.Parameters.Clear();
330 } 335 }
331 } 336 }
337 dbcon.Close();
332 } 338 }
333 } 339 }
334 340
@@ -358,6 +364,7 @@ namespace OpenSim.Data.MySQL
358 cmd.Parameters.Clear(); 364 cmd.Parameters.Clear();
359 } 365 }
360 } 366 }
367 dbcon.Close();
361 } 368 }
362 } 369 }
363 370
@@ -383,6 +390,7 @@ namespace OpenSim.Data.MySQL
383 } 390 }
384 } 391 }
385 } 392 }
393 dbcon.Close();
386 } 394 }
387 395
388 return uuids.ToArray(); 396 return uuids.ToArray();
@@ -437,7 +445,6 @@ namespace OpenSim.Data.MySQL
437 reader.Close(); 445 reader.Close();
438 } 446 }
439 } 447 }
440
441 dbcon.Close(); 448 dbcon.Close();
442 } 449 }
443 450
@@ -466,7 +473,6 @@ namespace OpenSim.Data.MySQL
466 reader.Close(); 473 reader.Close();
467 } 474 }
468 } 475 }
469
470 dbcon.Close(); 476 dbcon.Close();
471 } 477 }
472 478
diff --git a/OpenSim/Data/MySQL/MySQLFSAssetData.cs b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
index 2837ce3..6c48607 100644
--- a/OpenSim/Data/MySQL/MySQLFSAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLFSAssetData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
78 conn.Open(); 78 conn.Open();
79 Migration m = new Migration(conn, Assembly, "FSAssetStore"); 79 Migration m = new Migration(conn, Assembly, "FSAssetStore");
80 m.Update(); 80 m.Update();
81 conn.Close();
81 } 82 }
82 } 83 }
83 catch (MySqlException e) 84 catch (MySqlException e)
@@ -121,9 +122,13 @@ namespace OpenSim.Data.MySQL
121 } 122 }
122 catch (MySqlException e) 123 catch (MySqlException e)
123 { 124 {
125 cmd.Connection = null;
126 conn.Close();
124 m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString()); 127 m_log.ErrorFormat("[FSASSETS]: Query {0} failed with {1}", cmd.CommandText, e.ToString());
125 return false; 128 return false;
126 } 129 }
130 conn.Close();
131 cmd.Connection = null;
127 } 132 }
128 133
129 return true; 134 return true;
@@ -175,7 +180,7 @@ namespace OpenSim.Data.MySQL
175 UpdateAccessTime(id, AccessTime); 180 UpdateAccessTime(id, AccessTime);
176 } 181 }
177 } 182 }
178 183 conn.Close();
179 } 184 }
180 185
181 return meta; 186 return meta;
@@ -206,6 +211,7 @@ namespace OpenSim.Data.MySQL
206 cmd.Parameters.AddWithValue("?id", AssetID); 211 cmd.Parameters.AddWithValue("?id", AssetID);
207 cmd.ExecuteNonQuery(); 212 cmd.ExecuteNonQuery();
208 } 213 }
214 conn.Close();
209 } 215 }
210 } 216 }
211 217
@@ -299,6 +305,7 @@ namespace OpenSim.Data.MySQL
299 } 305 }
300 } 306 }
301 } 307 }
308 conn.Close();
302 } 309 }
303 310
304 for (int i = 0; i < uuids.Length; i++) 311 for (int i = 0; i < uuids.Length; i++)
@@ -333,6 +340,7 @@ namespace OpenSim.Data.MySQL
333 count = Convert.ToInt32(reader["count"]); 340 count = Convert.ToInt32(reader["count"]);
334 } 341 }
335 } 342 }
343 conn.Close();
336 } 344 }
337 345
338 return count; 346 return count;
@@ -413,8 +421,8 @@ namespace OpenSim.Data.MySQL
413 imported++; 421 imported++;
414 } 422 }
415 } 423 }
416
417 } 424 }
425 importConn.Close();
418 } 426 }
419 427
420 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported)); 428 MainConsole.Instance.Output(String.Format("Import done, {0} assets imported", imported));
diff --git a/OpenSim/Data/MySQL/MySQLFramework.cs b/OpenSim/Data/MySQL/MySQLFramework.cs
index 93662db..98106f0 100644
--- a/OpenSim/Data/MySQL/MySQLFramework.cs
+++ b/OpenSim/Data/MySQL/MySQLFramework.cs
@@ -74,7 +74,9 @@ namespace OpenSim.Data.MySQL
74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 74 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
75 { 75 {
76 dbcon.Open(); 76 dbcon.Open();
77 return ExecuteNonQueryWithConnection(cmd, dbcon); 77 int ret = ExecuteNonQueryWithConnection(cmd, dbcon);
78 dbcon.Close();
79 return ret;
78 } 80 }
79 } 81 }
80 else 82 else
@@ -97,12 +99,15 @@ namespace OpenSim.Data.MySQL
97 99
98 try 100 try
99 { 101 {
100 return cmd.ExecuteNonQuery(); 102 int ret = cmd.ExecuteNonQuery();
103 cmd.Connection = null;
104 return ret;
101 } 105 }
102 catch (Exception e) 106 catch (Exception e)
103 { 107 {
104 m_log.Error(e.Message, e); 108 m_log.Error(e.Message, e);
105 m_log.Error(Environment.StackTrace.ToString()); 109 m_log.Error(Environment.StackTrace.ToString());
110 cmd.Connection = null;
106 return 0; 111 return 0;
107 } 112 }
108 } 113 }
diff --git a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
index bd8bbd5..9bd3c0c 100644
--- a/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
+++ b/OpenSim/Data/MySQL/MySQLGenericTableHandler.cs
@@ -160,8 +160,9 @@ namespace OpenSim.Data.MySQL
160 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 160 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
161 { 161 {
162 dbcon.Open(); 162 dbcon.Open();
163 163 T[] ret = DoQueryWithConnection(cmd, dbcon);
164 return DoQueryWithConnection(cmd, dbcon); 164 dbcon.Close();
165 return ret;
165 } 166 }
166 } 167 }
167 else 168 else
@@ -243,7 +244,7 @@ namespace OpenSim.Data.MySQL
243 result.Add(row); 244 result.Add(row);
244 } 245 }
245 } 246 }
246 247 cmd.Connection = null;
247 return result.ToArray(); 248 return result.ToArray();
248 } 249 }
249 250
@@ -402,7 +403,10 @@ namespace OpenSim.Data.MySQL
402 dbcon.Open(); 403 dbcon.Open();
403 cmd.Connection = dbcon; 404 cmd.Connection = dbcon;
404 405
405 return cmd.ExecuteScalar(); 406 Object ret = cmd.ExecuteScalar();
407 cmd.Connection = null;
408 dbcon.Close();
409 return ret;
406 } 410 }
407 } 411 }
408 else 412 else
diff --git a/OpenSim/Data/MySQL/MySQLInventoryData.cs b/OpenSim/Data/MySQL/MySQLInventoryData.cs
index 382d4a5..cc787cc 100644
--- a/OpenSim/Data/MySQL/MySQLInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLInventoryData.cs
@@ -78,6 +78,7 @@ namespace OpenSim.Data.MySQL
78 dbcon.Open(); 78 dbcon.Open();
79 Migration m = new Migration(dbcon, assem, "InventoryStore"); 79 Migration m = new Migration(dbcon, assem, "InventoryStore");
80 m.Update(); 80 m.Update();
81 dbcon.Close();
81 } 82 }
82 } 83 }
83 84
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130 items.Add(item); 131 items.Add(item);
131 } 132 }
132 133
134 dbcon.Close();
133 return items; 135 return items;
134 } 136 }
135 } 137 }
@@ -170,6 +172,7 @@ namespace OpenSim.Data.MySQL
170 while (reader.Read()) 172 while (reader.Read())
171 items.Add(readInventoryFolder(reader)); 173 items.Add(readInventoryFolder(reader));
172 174
175 dbcon.Close();
173 return items; 176 return items;
174 } 177 }
175 } 178 }
@@ -221,6 +224,7 @@ namespace OpenSim.Data.MySQL
221 if (items.Count > 0) 224 if (items.Count > 0)
222 rootFolder = items[0]; 225 rootFolder = items[0];
223 226
227 dbcon.Close();
224 return rootFolder; 228 return rootFolder;
225 } 229 }
226 } 230 }
@@ -261,6 +265,7 @@ namespace OpenSim.Data.MySQL
261 while (reader.Read()) 265 while (reader.Read())
262 items.Add(readInventoryFolder(reader)); 266 items.Add(readInventoryFolder(reader));
263 267
268 dbcon.Close();
264 return items; 269 return items;
265 } 270 }
266 } 271 }
@@ -352,6 +357,7 @@ namespace OpenSim.Data.MySQL
352 if (reader.Read()) 357 if (reader.Read())
353 item = readInventoryItem(reader); 358 item = readInventoryItem(reader);
354 359
360 dbcon.Close();
355 return item; 361 return item;
356 } 362 }
357 } 363 }
@@ -417,6 +423,7 @@ namespace OpenSim.Data.MySQL
417 if (reader.Read()) 423 if (reader.Read())
418 folder = readInventoryFolder(reader); 424 folder = readInventoryFolder(reader);
419 425
426 dbcon.Close();
420 return folder; 427 return folder;
421 } 428 }
422 } 429 }
@@ -504,6 +511,7 @@ namespace OpenSim.Data.MySQL
504 lock (m_dbLock) 511 lock (m_dbLock)
505 result.ExecuteNonQuery(); 512 result.ExecuteNonQuery();
506 } 513 }
514 dbcon.Close();
507 } 515 }
508 } 516 }
509 catch (MySqlException e) 517 catch (MySqlException e)
@@ -540,6 +548,7 @@ namespace OpenSim.Data.MySQL
540 lock (m_dbLock) 548 lock (m_dbLock)
541 cmd.ExecuteNonQuery(); 549 cmd.ExecuteNonQuery();
542 } 550 }
551 dbcon.Close();
543 } 552 }
544 } 553 }
545 catch (MySqlException e) 554 catch (MySqlException e)
@@ -600,6 +609,7 @@ namespace OpenSim.Data.MySQL
600 m_log.Error(e.ToString()); 609 m_log.Error(e.ToString());
601 } 610 }
602 } 611 }
612 dbcon.Close();
603 } 613 }
604 } 614 }
605 615
@@ -643,6 +653,7 @@ namespace OpenSim.Data.MySQL
643 m_log.Error(e.ToString()); 653 m_log.Error(e.ToString());
644 } 654 }
645 } 655 }
656 dbcon.Close();
646 } 657 }
647 } 658 }
648 659
@@ -806,6 +817,7 @@ namespace OpenSim.Data.MySQL
806 lock (m_dbLock) 817 lock (m_dbLock)
807 cmd.ExecuteNonQuery(); 818 cmd.ExecuteNonQuery();
808 } 819 }
820 dbcon.Close();
809 } 821 }
810 } 822 }
811 catch (MySqlException e) 823 catch (MySqlException e)
@@ -833,6 +845,7 @@ namespace OpenSim.Data.MySQL
833 lock (m_dbLock) 845 lock (m_dbLock)
834 cmd.ExecuteNonQuery(); 846 cmd.ExecuteNonQuery();
835 } 847 }
848 dbcon.Close();
836 } 849 }
837 } 850 }
838 catch (MySqlException e) 851 catch (MySqlException e)
@@ -886,6 +899,7 @@ namespace OpenSim.Data.MySQL
886 if (item != null) 899 if (item != null)
887 list.Add(item); 900 list.Add(item);
888 } 901 }
902 dbcon.Close();
889 return list; 903 return list;
890 } 904 }
891 } 905 }
diff --git a/OpenSim/Data/MySQL/MySQLRegionData.cs b/OpenSim/Data/MySQL/MySQLRegionData.cs
index 0e55285..46df421 100644
--- a/OpenSim/Data/MySQL/MySQLRegionData.cs
+++ b/OpenSim/Data/MySQL/MySQLRegionData.cs
@@ -60,6 +60,7 @@ namespace OpenSim.Data.MySQL
60 dbcon.Open(); 60 dbcon.Open();
61 Migration m = new Migration(dbcon, Assembly, "GridStore"); 61 Migration m = new Migration(dbcon, Assembly, "GridStore");
62 m.Update(); 62 m.Update();
63 dbcon.Close();
63 } 64 }
64 } 65 }
65 66
@@ -260,6 +261,8 @@ namespace OpenSim.Data.MySQL
260 retList.Add(ret); 261 retList.Add(ret);
261 } 262 }
262 } 263 }
264 cmd.Connection = null;
265 dbcon.Close();
263 } 266 }
264 267
265 return retList; 268 return retList;
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 5740b91..4766372 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -88,6 +88,7 @@ namespace OpenSim.Data.MySQL
88 // 88 //
89 Migration m = new Migration(dbcon, Assembly, "RegionStore"); 89 Migration m = new Migration(dbcon, Assembly, "RegionStore");
90 m.Update(); 90 m.Update();
91 dbcon.Close();
91 } 92 }
92 } 93 }
93 94
@@ -261,6 +262,7 @@ namespace OpenSim.Data.MySQL
261 ExecuteNonQuery(cmd); 262 ExecuteNonQuery(cmd);
262 } 263 }
263 } 264 }
265 dbcon.Close();
264 } 266 }
265 } 267 }
266 } 268 }
@@ -300,6 +302,7 @@ namespace OpenSim.Data.MySQL
300 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID"; 302 cmd.CommandText = "delete from prims where SceneGroupID= ?UUID";
301 ExecuteNonQuery(cmd); 303 ExecuteNonQuery(cmd);
302 } 304 }
305 dbcon.Close();
303 } 306 }
304 } 307 }
305 308
@@ -334,6 +337,7 @@ namespace OpenSim.Data.MySQL
334 337
335 ExecuteNonQuery(cmd); 338 ExecuteNonQuery(cmd);
336 } 339 }
340 dbcon.Close();
337 } 341 }
338 } 342 }
339 } 343 }
@@ -372,6 +376,7 @@ namespace OpenSim.Data.MySQL
372 376
373 ExecuteNonQuery(cmd); 377 ExecuteNonQuery(cmd);
374 } 378 }
379 dbcon.Close();
375 } 380 }
376 } 381 }
377 } 382 }
@@ -411,6 +416,7 @@ namespace OpenSim.Data.MySQL
411 416
412 ExecuteNonQuery(cmd); 417 ExecuteNonQuery(cmd);
413 } 418 }
419 dbcon.Close();
414 } 420 }
415 } 421 }
416 } 422 }
@@ -460,6 +466,7 @@ namespace OpenSim.Data.MySQL
460 } 466 }
461 } 467 }
462 } 468 }
469 dbcon.Close();
463 } 470 }
464 } 471 }
465 472
@@ -535,6 +542,7 @@ namespace OpenSim.Data.MySQL
535 } 542 }
536 } 543 }
537 } 544 }
545 dbcon.Close();
538 } 546 }
539 } 547 }
540 548
@@ -580,6 +588,7 @@ namespace OpenSim.Data.MySQL
580 } 588 }
581 } 589 }
582 } 590 }
591 dbcon.Close();
583 } 592 }
584 593
585 prim.Inventory.RestoreInventoryItems(inventory); 594 prim.Inventory.RestoreInventoryItems(inventory);
@@ -634,6 +643,7 @@ namespace OpenSim.Data.MySQL
634 } 643 }
635 } 644 }
636 } 645 }
646 dbcon.Close();
637 } 647 }
638 } 648 }
639 }); 649 });
@@ -681,6 +691,7 @@ namespace OpenSim.Data.MySQL
681 } 691 }
682 } 692 }
683 } 693 }
694 dbcon.Close();
684 } 695 }
685 } 696 }
686 }); 697 });
@@ -727,6 +738,7 @@ namespace OpenSim.Data.MySQL
727 } 738 }
728 } 739 }
729 } 740 }
741 dbcon.Close();
730 } 742 }
731 } 743 }
732 744
@@ -762,6 +774,7 @@ namespace OpenSim.Data.MySQL
762 } 774 }
763 } 775 }
764 } 776 }
777 dbcon.Close();
765 } 778 }
766 } 779 }
767 780
@@ -783,6 +796,7 @@ namespace OpenSim.Data.MySQL
783 796
784 ExecuteNonQuery(cmd); 797 ExecuteNonQuery(cmd);
785 } 798 }
799 dbcon.Close();
786 } 800 }
787 } 801 }
788 } 802 }
@@ -842,6 +856,7 @@ namespace OpenSim.Data.MySQL
842 cmd.Parameters.Clear(); 856 cmd.Parameters.Clear();
843 } 857 }
844 } 858 }
859 dbcon.Close();
845 } 860 }
846 } 861 }
847 } 862 }
@@ -863,82 +878,85 @@ namespace OpenSim.Data.MySQL
863 878
864 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); 879 cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString());
865 880
866 IDataReader result = ExecuteReader(cmd); 881 using(IDataReader result = ExecuteReader(cmd))
867 if (!result.Read())
868 { 882 {
869 //No result, so store our default windlight profile and return it 883 if(!result.Read())
870 nWP.regionID = regionUUID; 884 {
871// StoreRegionWindlightSettings(nWP); 885 //No result, so store our default windlight profile and return it
872 return nWP; 886 nWP.regionID = regionUUID;
873 } 887 // StoreRegionWindlightSettings(nWP);
874 else 888 return nWP;
875 { 889 }
876 nWP.regionID = DBGuid.FromDB(result["region_id"]); 890 else
877 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); 891 {
878 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); 892 nWP.regionID = DBGuid.FromDB(result["region_id"]);
879 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); 893 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
880 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); 894 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
881 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); 895 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
882 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); 896 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
883 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); 897 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
884 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); 898 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
885 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); 899 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
886 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); 900 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
887 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); 901 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
888 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); 902 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
889 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); 903 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
890 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); 904 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
891 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); 905 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
892 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); 906 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
893 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); 907 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
894 UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); 908 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
895 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); 909 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
896 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); 910 UUID.TryParse(result["normal_map_texture"].ToString(),out nWP.normalMapTexture);
897 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); 911 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
898 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); 912 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
899 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); 913 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
900 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); 914 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
901 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); 915 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
902 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); 916 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
903 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); 917 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
904 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); 918 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
905 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); 919 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
906 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); 920 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
907 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); 921 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
908 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); 922 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
909 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); 923 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
910 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); 924 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
911 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); 925 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
912 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); 926 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
913 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); 927 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
914 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); 928 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
915 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); 929 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
916 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); 930 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
917 nWP.eastAngle = Convert.ToSingle(result["east_angle"]); 931 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
918 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); 932 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
919 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); 933 nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
920 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); 934 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
921 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); 935 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
922 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); 936 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
923 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); 937 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
924 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); 938 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
925 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); 939 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
926 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); 940 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
927 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); 941 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
928 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); 942 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
929 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); 943 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
930 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); 944 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
931 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); 945 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
932 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); 946 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
933 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); 947 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
934 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); 948 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
935 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); 949 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
936 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); 950 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
937 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); 951 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
938 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); 952 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
939 nWP.valid = true; 953 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
954 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
955 nWP.valid = true;
956 }
940 } 957 }
941 } 958 }
959 dbcon.Close();
942 } 960 }
943 961
944 return nWP; 962 return nWP;
@@ -947,6 +965,7 @@ namespace OpenSim.Data.MySQL
947 public virtual RegionSettings LoadRegionSettings(UUID regionUUID) 965 public virtual RegionSettings LoadRegionSettings(UUID regionUUID)
948 { 966 {
949 RegionSettings rs = null; 967 RegionSettings rs = null;
968 bool needStore = false;
950 969
951 lock (m_dbLock) 970 lock (m_dbLock)
952 { 971 {
@@ -972,13 +991,17 @@ namespace OpenSim.Data.MySQL
972 rs.RegionUUID = regionUUID; 991 rs.RegionUUID = regionUUID;
973 rs.OnSave += StoreRegionSettings; 992 rs.OnSave += StoreRegionSettings;
974 993
975 StoreRegionSettings(rs); 994 needStore = true;
976 } 995 }
977 } 996 }
978 } 997 }
998 dbcon.Close();
979 } 999 }
980 } 1000 }
981 1001
1002 if(needStore)
1003 StoreRegionSettings(rs);
1004
982 LoadSpawnPoints(rs); 1005 LoadSpawnPoints(rs);
983 1006
984 return rs; 1007 return rs;
@@ -992,31 +1015,32 @@ namespace OpenSim.Data.MySQL
992 1015
993 using (MySqlCommand cmd = dbcon.CreateCommand()) 1016 using (MySqlCommand cmd = dbcon.CreateCommand())
994 { 1017 {
995 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "; 1018 cmd.CommandText = "REPLACE INTO `regionwindlight` (`region_id`, `water_color_r`, `water_color_g`, "
996 cmd.CommandText += "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "; 1019 + "`water_color_b`, `water_fog_density_exponent`, `underwater_fog_modifier`, "
997 cmd.CommandText += "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "; 1020 + "`reflection_wavelet_scale_1`, `reflection_wavelet_scale_2`, `reflection_wavelet_scale_3`, "
998 cmd.CommandText += "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "; 1021 + "`fresnel_scale`, `fresnel_offset`, `refract_scale_above`, `refract_scale_below`, "
999 cmd.CommandText += "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "; 1022 + "`blur_multiplier`, `big_wave_direction_x`, `big_wave_direction_y`, `little_wave_direction_x`, "
1000 cmd.CommandText += "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "; 1023 + "`little_wave_direction_y`, `normal_map_texture`, `horizon_r`, `horizon_g`, `horizon_b`, "
1001 cmd.CommandText += "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "; 1024 + "`horizon_i`, `haze_horizon`, `blue_density_r`, `blue_density_g`, `blue_density_b`, "
1002 cmd.CommandText += "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "; 1025 + "`blue_density_i`, `haze_density`, `density_multiplier`, `distance_multiplier`, `max_altitude`, "
1003 cmd.CommandText += "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "; 1026 + "`sun_moon_color_r`, `sun_moon_color_g`, `sun_moon_color_b`, `sun_moon_color_i`, `sun_moon_position`, "
1004 cmd.CommandText += "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "; 1027 + "`ambient_r`, `ambient_g`, `ambient_b`, `ambient_i`, `east_angle`, `sun_glow_focus`, `sun_glow_size`, "
1005 cmd.CommandText += "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "; 1028 + "`scene_gamma`, `star_brightness`, `cloud_color_r`, `cloud_color_g`, `cloud_color_b`, `cloud_color_i`, "
1006 cmd.CommandText += "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "; 1029 + "`cloud_x`, `cloud_y`, `cloud_density`, `cloud_coverage`, `cloud_scale`, `cloud_detail_x`, "
1007 cmd.CommandText += "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "; 1030 + "`cloud_detail_y`, `cloud_detail_density`, `cloud_scroll_x`, `cloud_scroll_x_lock`, `cloud_scroll_y`, "
1008 cmd.CommandText += "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "; 1031 + "`cloud_scroll_y_lock`, `draw_classic_clouds`) VALUES (?region_id, ?water_color_r, "
1009 cmd.CommandText += "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "; 1032 + "?water_color_g, ?water_color_b, ?water_fog_density_exponent, ?underwater_fog_modifier, ?reflection_wavelet_scale_1, "
1010 cmd.CommandText += "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "; 1033 + "?reflection_wavelet_scale_2, ?reflection_wavelet_scale_3, ?fresnel_scale, ?fresnel_offset, ?refract_scale_above, "
1011 cmd.CommandText += "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "; 1034 + "?refract_scale_below, ?blur_multiplier, ?big_wave_direction_x, ?big_wave_direction_y, ?little_wave_direction_x, "
1012 cmd.CommandText += "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "; 1035 + "?little_wave_direction_y, ?normal_map_texture, ?horizon_r, ?horizon_g, ?horizon_b, ?horizon_i, ?haze_horizon, "
1013 cmd.CommandText += "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "; 1036 + "?blue_density_r, ?blue_density_g, ?blue_density_b, ?blue_density_i, ?haze_density, ?density_multiplier, "
1014 cmd.CommandText += "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "; 1037 + "?distance_multiplier, ?max_altitude, ?sun_moon_color_r, ?sun_moon_color_g, ?sun_moon_color_b, "
1015 cmd.CommandText += "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "; 1038 + "?sun_moon_color_i, ?sun_moon_position, ?ambient_r, ?ambient_g, ?ambient_b, ?ambient_i, ?east_angle, "
1016 cmd.CommandText += "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "; 1039 + "?sun_glow_focus, ?sun_glow_size, ?scene_gamma, ?star_brightness, ?cloud_color_r, ?cloud_color_g, "
1017 cmd.CommandText += "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "; 1040 + "?cloud_color_b, ?cloud_color_i, ?cloud_x, ?cloud_y, ?cloud_density, ?cloud_coverage, ?cloud_scale, "
1018 cmd.CommandText += "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "; 1041 + "?cloud_detail_x, ?cloud_detail_y, ?cloud_detail_density, ?cloud_scroll_x, ?cloud_scroll_x_lock, "
1019 cmd.CommandText += "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"; 1042 + "?cloud_scroll_y, ?cloud_scroll_y_lock, ?draw_classic_clouds)"
1043 ;
1020 1044
1021 cmd.Parameters.AddWithValue("region_id", wl.regionID); 1045 cmd.Parameters.AddWithValue("region_id", wl.regionID);
1022 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X); 1046 cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
@@ -1084,6 +1108,7 @@ namespace OpenSim.Data.MySQL
1084 1108
1085 ExecuteNonQuery(cmd); 1109 ExecuteNonQuery(cmd);
1086 } 1110 }
1111 dbcon.Close();
1087 } 1112 }
1088 } 1113 }
1089 1114
@@ -1099,6 +1124,7 @@ namespace OpenSim.Data.MySQL
1099 cmd.Parameters.AddWithValue("?regionID", regionID.ToString()); 1124 cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
1100 ExecuteNonQuery(cmd); 1125 ExecuteNonQuery(cmd);
1101 } 1126 }
1127 dbcon.Close();
1102 } 1128 }
1103 } 1129 }
1104 1130
@@ -1117,14 +1143,19 @@ namespace OpenSim.Data.MySQL
1117 1143
1118 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1144 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1119 1145
1120 IDataReader result = ExecuteReader(cmd); 1146 using(IDataReader result = ExecuteReader(cmd))
1121 if (!result.Read())
1122 { 1147 {
1123 return String.Empty; 1148 if(!result.Read())
1124 } 1149 {
1125 else 1150 dbcon.Close();
1126 { 1151 return String.Empty;
1127 return Convert.ToString(result["llsd_settings"]); 1152 }
1153 else
1154 {
1155 string ret = Convert.ToString(result["llsd_settings"]);
1156 dbcon.Close();
1157 return ret;
1158 }
1128 } 1159 }
1129 } 1160 }
1130 } 1161 }
@@ -1145,6 +1176,7 @@ namespace OpenSim.Data.MySQL
1145 1176
1146 ExecuteNonQuery(cmd); 1177 ExecuteNonQuery(cmd);
1147 } 1178 }
1179 dbcon.Close();
1148 } 1180 }
1149 } 1181 }
1150 1182
@@ -1160,6 +1192,7 @@ namespace OpenSim.Data.MySQL
1160 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); 1192 cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString());
1161 ExecuteNonQuery(cmd); 1193 ExecuteNonQuery(cmd);
1162 } 1194 }
1195 dbcon.Close();
1163 } 1196 }
1164 } 1197 }
1165 #endregion 1198 #endregion
@@ -1212,7 +1245,7 @@ namespace OpenSim.Data.MySQL
1212 FillRegionSettingsCommand(cmd, rs); 1245 FillRegionSettingsCommand(cmd, rs);
1213 ExecuteNonQuery(cmd); 1246 ExecuteNonQuery(cmd);
1214 } 1247 }
1215 1248 dbcon.Close();
1216 SaveSpawnPoints(rs); 1249 SaveSpawnPoints(rs);
1217 } 1250 }
1218 } 1251 }
@@ -1259,6 +1292,7 @@ namespace OpenSim.Data.MySQL
1259 } 1292 }
1260 } 1293 }
1261 } 1294 }
1295 dbcon.Close();
1262 } 1296 }
1263 } 1297 }
1264 1298
@@ -2123,6 +2157,7 @@ namespace OpenSim.Data.MySQL
2123 ExecuteNonQuery(cmd); 2157 ExecuteNonQuery(cmd);
2124 } 2158 }
2125 } 2159 }
2160 dbcon.Close();
2126 } 2161 }
2127 } 2162 }
2128 } 2163 }
@@ -2152,6 +2187,7 @@ namespace OpenSim.Data.MySQL
2152 } 2187 }
2153 } 2188 }
2154 } 2189 }
2190 dbcon.Close();
2155 } 2191 }
2156 } 2192 }
2157 2193
@@ -2187,6 +2223,7 @@ namespace OpenSim.Data.MySQL
2187 } 2223 }
2188 } 2224 }
2189 } 2225 }
2226 dbcon.Close();
2190 } 2227 }
2191 } 2228 }
2192 } 2229 }
@@ -2221,6 +2258,7 @@ namespace OpenSim.Data.MySQL
2221 cmd.Parameters.Clear(); 2258 cmd.Parameters.Clear();
2222 } 2259 }
2223 } 2260 }
2261 dbcon.Close();
2224 } 2262 }
2225 } 2263 }
2226 } 2264 }
@@ -2240,6 +2278,7 @@ namespace OpenSim.Data.MySQL
2240 2278
2241 cmd.ExecuteNonQuery(); 2279 cmd.ExecuteNonQuery();
2242 } 2280 }
2281 dbcon.Close();
2243 } 2282 }
2244 } 2283 }
2245 2284
@@ -2257,6 +2296,7 @@ namespace OpenSim.Data.MySQL
2257 2296
2258 cmd.ExecuteNonQuery(); 2297 cmd.ExecuteNonQuery();
2259 } 2298 }
2299 dbcon.Close();
2260 } 2300 }
2261 } 2301 }
2262 2302
@@ -2280,6 +2320,7 @@ namespace OpenSim.Data.MySQL
2280 } 2320 }
2281 } 2321 }
2282 } 2322 }
2323 dbcon.Close();
2283 } 2324 }
2284 2325
2285 return ret; 2326 return ret;
diff --git a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
index 8af2a3e..c98e017 100644
--- a/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
+++ b/OpenSim/Data/MySQL/MySQLUserProfilesData.cs
@@ -69,6 +69,7 @@ namespace OpenSim.Data.MySQL
69 69
70 Migration m = new Migration(dbcon, Assembly, "UserProfiles"); 70 Migration m = new Migration(dbcon, Assembly, "UserProfiles");
71 m.Update(); 71 m.Update();
72 dbcon.Close();
72 } 73 }
73 } 74 }
74 #endregion Member Functions 75 #endregion Member Functions
@@ -89,7 +90,7 @@ namespace OpenSim.Data.MySQL
89 90
90 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 91 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
91 { 92 {
92 string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id"; 93 const string query = "SELECT classifieduuid, name FROM classifieds WHERE creatoruuid = ?Id";
93 dbcon.Open(); 94 dbcon.Open();
94 using (MySqlCommand cmd = new MySqlCommand(query, dbcon)) 95 using (MySqlCommand cmd = new MySqlCommand(query, dbcon))
95 { 96 {
@@ -121,58 +122,58 @@ namespace OpenSim.Data.MySQL
121 } 122 }
122 } 123 }
123 } 124 }
125 dbcon.Close();
124 } 126 }
125 return data; 127 return data;
126 } 128 }
127 129
128 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result) 130 public bool UpdateClassifiedRecord(UserClassifiedAdd ad, ref string result)
129 { 131 {
130 string query = string.Empty; 132 const string query =
131 133 "INSERT INTO classifieds ("
132 134 + "`classifieduuid`,"
133 query += "INSERT INTO classifieds ("; 135 + "`creatoruuid`,"
134 query += "`classifieduuid`,"; 136 + "`creationdate`,"
135 query += "`creatoruuid`,"; 137 + "`expirationdate`,"
136 query += "`creationdate`,"; 138 + "`category`,"
137 query += "`expirationdate`,"; 139 + "`name`,"
138 query += "`category`,"; 140 + "`description`,"
139 query += "`name`,"; 141 + "`parceluuid`,"
140 query += "`description`,"; 142 + "`parentestate`,"
141 query += "`parceluuid`,"; 143 + "`snapshotuuid`,"
142 query += "`parentestate`,"; 144 + "`simname`,"
143 query += "`snapshotuuid`,"; 145 + "`posglobal`,"
144 query += "`simname`,"; 146 + "`parcelname`,"
145 query += "`posglobal`,"; 147 + "`classifiedflags`,"
146 query += "`parcelname`,"; 148 + "`priceforlisting`) "
147 query += "`classifiedflags`,"; 149 + "VALUES ("
148 query += "`priceforlisting`) "; 150 + "?ClassifiedId,"
149 query += "VALUES ("; 151 + "?CreatorId,"
150 query += "?ClassifiedId,"; 152 + "?CreatedDate,"
151 query += "?CreatorId,"; 153 + "?ExpirationDate,"
152 query += "?CreatedDate,"; 154 + "?Category,"
153 query += "?ExpirationDate,"; 155 + "?Name,"
154 query += "?Category,"; 156 + "?Description,"
155 query += "?Name,"; 157 + "?ParcelId,"
156 query += "?Description,"; 158 + "?ParentEstate,"
157 query += "?ParcelId,"; 159 + "?SnapshotId,"
158 query += "?ParentEstate,"; 160 + "?SimName,"
159 query += "?SnapshotId,"; 161 + "?GlobalPos,"
160 query += "?SimName,"; 162 + "?ParcelName,"
161 query += "?GlobalPos,"; 163 + "?Flags,"
162 query += "?ParcelName,"; 164 + "?ListingPrice ) "
163 query += "?Flags,"; 165 + "ON DUPLICATE KEY UPDATE "
164 query += "?ListingPrice ) "; 166 + "category=?Category, "
165 query += "ON DUPLICATE KEY UPDATE "; 167 + "expirationdate=?ExpirationDate, "
166 query += "category=?Category, "; 168 + "name=?Name, "
167 query += "expirationdate=?ExpirationDate, "; 169 + "description=?Description, "
168 query += "name=?Name, "; 170 + "parentestate=?ParentEstate, "
169 query += "description=?Description, "; 171 + "posglobal=?GlobalPos, "
170 query += "parentestate=?ParentEstate, "; 172 + "parcelname=?ParcelName, "
171 query += "posglobal=?GlobalPos, "; 173 + "classifiedflags=?Flags, "
172 query += "parcelname=?ParcelName, "; 174 + "priceforlisting=?ListingPrice, "
173 query += "classifiedflags=?Flags, "; 175 + "snapshotuuid=?SnapshotId"
174 query += "priceforlisting=?ListingPrice, "; 176 ;
175 query += "snapshotuuid=?SnapshotId";
176 177
177 if(string.IsNullOrEmpty(ad.ParcelName)) 178 if(string.IsNullOrEmpty(ad.ParcelName))
178 ad.ParcelName = "Unknown"; 179 ad.ParcelName = "Unknown";
@@ -228,6 +229,7 @@ namespace OpenSim.Data.MySQL
228 229
229 cmd.ExecuteNonQuery(); 230 cmd.ExecuteNonQuery();
230 } 231 }
232 dbcon.Close();
231 } 233 }
232 } 234 }
233 catch (Exception e) 235 catch (Exception e)
@@ -242,10 +244,7 @@ namespace OpenSim.Data.MySQL
242 244
243 public bool DeleteClassifiedRecord(UUID recordId) 245 public bool DeleteClassifiedRecord(UUID recordId)
244 { 246 {
245 string query = string.Empty; 247 const string query = "DELETE FROM classifieds WHERE classifieduuid = ?recordId";
246
247 query += "DELETE FROM classifieds WHERE ";
248 query += "classifieduuid = ?recordId";
249 248
250 try 249 try
251 { 250 {
@@ -258,6 +257,7 @@ namespace OpenSim.Data.MySQL
258 cmd.Parameters.AddWithValue("?recordId", recordId.ToString()); 257 cmd.Parameters.AddWithValue("?recordId", recordId.ToString());
259 cmd.ExecuteNonQuery(); 258 cmd.ExecuteNonQuery();
260 } 259 }
260 dbcon.Close();
261 } 261 }
262 } 262 }
263 catch (Exception e) 263 catch (Exception e)
@@ -271,10 +271,8 @@ namespace OpenSim.Data.MySQL
271 271
272 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result) 272 public bool GetClassifiedInfo(ref UserClassifiedAdd ad, ref string result)
273 { 273 {
274 string query = string.Empty;
275 274
276 query += "SELECT * FROM classifieds WHERE "; 275 const string query = "SELECT * FROM classifieds WHERE classifieduuid = ?AdId";
277 query += "classifieduuid = ?AdId";
278 276
279 try 277 try
280 { 278 {
@@ -322,10 +320,8 @@ namespace OpenSim.Data.MySQL
322 #region Picks Queries 320 #region Picks Queries
323 public OSDArray GetAvatarPicks(UUID avatarId) 321 public OSDArray GetAvatarPicks(UUID avatarId)
324 { 322 {
325 string query = string.Empty; 323 const string query = "SELECT `pickuuid`,`name` FROM userpicks WHERE creatoruuid = ?Id";
326 324
327 query += "SELECT `pickuuid`,`name` FROM userpicks WHERE ";
328 query += "creatoruuid = ?Id";
329 OSDArray data = new OSDArray(); 325 OSDArray data = new OSDArray();
330 326
331 try 327 try
@@ -352,6 +348,7 @@ namespace OpenSim.Data.MySQL
352 } 348 }
353 } 349 }
354 } 350 }
351 dbcon.Close();
355 } 352 }
356 } 353 }
357 catch (Exception e) 354 catch (Exception e)
@@ -364,12 +361,8 @@ namespace OpenSim.Data.MySQL
364 361
365 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId) 362 public UserProfilePick GetPickInfo(UUID avatarId, UUID pickId)
366 { 363 {
367 string query = string.Empty;
368 UserProfilePick pick = new UserProfilePick(); 364 UserProfilePick pick = new UserProfilePick();
369 365 const string query = "SELECT * FROM userpicks WHERE creatoruuid = ?CreatorId AND pickuuid = ?PickId";
370 query += "SELECT * FROM userpicks WHERE ";
371 query += "creatoruuid = ?CreatorId AND ";
372 query += "pickuuid = ?PickId";
373 366
374 try 367 try
375 { 368 {
@@ -422,33 +415,33 @@ namespace OpenSim.Data.MySQL
422 415
423 public bool UpdatePicksRecord(UserProfilePick pick) 416 public bool UpdatePicksRecord(UserProfilePick pick)
424 { 417 {
425 string query = string.Empty; 418 const string query =
426 419 "INSERT INTO userpicks VALUES ("
427 query += "INSERT INTO userpicks VALUES ("; 420 + "?PickId,"
428 query += "?PickId,"; 421 + "?CreatorId,"
429 query += "?CreatorId,"; 422 + "?TopPick,"
430 query += "?TopPick,"; 423 + "?ParcelId,"
431 query += "?ParcelId,"; 424 + "?Name,"
432 query += "?Name,"; 425 + "?Desc,"
433 query += "?Desc,"; 426 + "?SnapshotId,"
434 query += "?SnapshotId,"; 427 + "?User,"
435 query += "?User,"; 428 + "?Original,"
436 query += "?Original,"; 429 + "?SimName,"
437 query += "?SimName,"; 430 + "?GlobalPos,"
438 query += "?GlobalPos,"; 431 + "?SortOrder,"
439 query += "?SortOrder,"; 432 + "?Enabled,"
440 query += "?Enabled,"; 433 + "?Gatekeeper)"
441 query += "?Gatekeeper)"; 434 + "ON DUPLICATE KEY UPDATE "
442 query += "ON DUPLICATE KEY UPDATE "; 435 + "parceluuid=?ParcelId,"
443 query += "parceluuid=?ParcelId,"; 436 + "name=?Name,"
444 query += "name=?Name,"; 437 + "description=?Desc,"
445 query += "description=?Desc,"; 438 + "user=?User,"
446 query += "user=?User,"; 439 + "simname=?SimName,"
447 query += "simname=?SimName,"; 440 + "snapshotuuid=?SnapshotId,"
448 query += "snapshotuuid=?SnapshotId,"; 441 + "pickuuid=?PickId,"
449 query += "pickuuid=?PickId,"; 442 + "posglobal=?GlobalPos,"
450 query += "posglobal=?GlobalPos,"; 443 + "gatekeeper=?Gatekeeper"
451 query += "gatekeeper=?Gatekeeper"; 444 ;
452 445
453 try 446 try
454 { 447 {
@@ -474,6 +467,7 @@ namespace OpenSim.Data.MySQL
474 467
475 cmd.ExecuteNonQuery(); 468 cmd.ExecuteNonQuery();
476 } 469 }
470 dbcon.Close();
477 } 471 }
478 } 472 }
479 catch (Exception e) 473 catch (Exception e)
@@ -487,10 +481,7 @@ namespace OpenSim.Data.MySQL
487 481
488 public bool DeletePicksRecord(UUID pickId) 482 public bool DeletePicksRecord(UUID pickId)
489 { 483 {
490 string query = string.Empty; 484 string query = "DELETE FROM userpicks WHERE pickuuid = ?PickId";
491
492 query += "DELETE FROM userpicks WHERE ";
493 query += "pickuuid = ?PickId";
494 485
495 try 486 try
496 { 487 {
@@ -504,6 +495,7 @@ namespace OpenSim.Data.MySQL
504 495
505 cmd.ExecuteNonQuery(); 496 cmd.ExecuteNonQuery();
506 } 497 }
498 dbcon.Close();
507 } 499 }
508 } 500 }
509 catch (Exception e) 501 catch (Exception e)
@@ -519,11 +511,7 @@ namespace OpenSim.Data.MySQL
519 #region Avatar Notes Queries 511 #region Avatar Notes Queries
520 public bool GetAvatarNotes(ref UserProfileNotes notes) 512 public bool GetAvatarNotes(ref UserProfileNotes notes)
521 { // WIP 513 { // WIP
522 string query = string.Empty; 514 const string query = "SELECT `notes` FROM usernotes WHERE useruuid = ?Id AND targetuuid = ?TargetId";
523
524 query += "SELECT `notes` FROM usernotes WHERE ";
525 query += "useruuid = ?Id AND ";
526 query += "targetuuid = ?TargetId";
527 515
528 try 516 try
529 { 517 {
@@ -548,6 +536,7 @@ namespace OpenSim.Data.MySQL
548 } 536 }
549 } 537 }
550 } 538 }
539 dbcon.Close();
551 } 540 }
552 } 541 }
553 catch (Exception e) 542 catch (Exception e)
@@ -560,26 +549,25 @@ namespace OpenSim.Data.MySQL
560 549
561 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result) 550 public bool UpdateAvatarNotes(ref UserProfileNotes note, ref string result)
562 { 551 {
563 string query = string.Empty; 552 string query;
564 bool remove; 553 bool remove;
565 554
566 if(string.IsNullOrEmpty(note.Notes)) 555 if(string.IsNullOrEmpty(note.Notes))
567 { 556 {
568 remove = true; 557 remove = true;
569 query += "DELETE FROM usernotes WHERE "; 558 query = "DELETE FROM usernotes WHERE useruuid=?UserId AND targetuuid=?TargetId";
570 query += "useruuid=?UserId AND ";
571 query += "targetuuid=?TargetId";
572 } 559 }
573 else 560 else
574 { 561 {
575 remove = false; 562 remove = false;
576 query += "INSERT INTO usernotes VALUES ( "; 563 query = "INSERT INTO usernotes VALUES ("
577 query += "?UserId,"; 564 + "?UserId,"
578 query += "?TargetId,"; 565 + "?TargetId,"
579 query += "?Notes )"; 566 + "?Notes )"
580 query += "ON DUPLICATE KEY "; 567 + "ON DUPLICATE KEY "
581 query += "UPDATE "; 568 + "UPDATE "
582 query += "notes=?Notes"; 569 + "notes=?Notes"
570 ;
583 } 571 }
584 572
585 try 573 try
@@ -596,6 +584,7 @@ namespace OpenSim.Data.MySQL
596 584
597 cmd.ExecuteNonQuery(); 585 cmd.ExecuteNonQuery();
598 } 586 }
587 dbcon.Close();
599 } 588 }
600 } 589 }
601 catch (Exception e) 590 catch (Exception e)
@@ -612,10 +601,7 @@ namespace OpenSim.Data.MySQL
612 #region Avatar Properties 601 #region Avatar Properties
613 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result) 602 public bool GetAvatarProperties(ref UserProfileProperties props, ref string result)
614 { 603 {
615 string query = string.Empty; 604 string query = "SELECT * FROM userprofile WHERE useruuid = ?Id";
616
617 query += "SELECT * FROM userprofile WHERE ";
618 query += "useruuid = ?Id";
619 605
620 try 606 try
621 { 607 {
@@ -664,35 +650,36 @@ namespace OpenSim.Data.MySQL
664 props.PublishProfile = false; 650 props.PublishProfile = false;
665 props.PublishMature = false; 651 props.PublishMature = false;
666 652
667 query = "INSERT INTO userprofile ("; 653 query = "INSERT INTO userprofile ("
668 query += "useruuid, "; 654 + "useruuid, "
669 query += "profilePartner, "; 655 + "profilePartner, "
670 query += "profileAllowPublish, "; 656 + "profileAllowPublish, "
671 query += "profileMaturePublish, "; 657 + "profileMaturePublish, "
672 query += "profileURL, "; 658 + "profileURL, "
673 query += "profileWantToMask, "; 659 + "profileWantToMask, "
674 query += "profileWantToText, "; 660 + "profileWantToText, "
675 query += "profileSkillsMask, "; 661 + "profileSkillsMask, "
676 query += "profileSkillsText, "; 662 + "profileSkillsText, "
677 query += "profileLanguages, "; 663 + "profileLanguages, "
678 query += "profileImage, "; 664 + "profileImage, "
679 query += "profileAboutText, "; 665 + "profileAboutText, "
680 query += "profileFirstImage, "; 666 + "profileFirstImage, "
681 query += "profileFirstText) VALUES ("; 667 + "profileFirstText) VALUES ("
682 query += "?userId, "; 668 + "?userId, "
683 query += "?profilePartner, "; 669 + "?profilePartner, "
684 query += "?profileAllowPublish, "; 670 + "?profileAllowPublish, "
685 query += "?profileMaturePublish, "; 671 + "?profileMaturePublish, "
686 query += "?profileURL, "; 672 + "?profileURL, "
687 query += "?profileWantToMask, "; 673 + "?profileWantToMask, "
688 query += "?profileWantToText, "; 674 + "?profileWantToText, "
689 query += "?profileSkillsMask, "; 675 + "?profileSkillsMask, "
690 query += "?profileSkillsText, "; 676 + "?profileSkillsText, "
691 query += "?profileLanguages, "; 677 + "?profileLanguages, "
692 query += "?profileImage, "; 678 + "?profileImage, "
693 query += "?profileAboutText, "; 679 + "?profileAboutText, "
694 query += "?profileFirstImage, "; 680 + "?profileFirstImage, "
695 query += "?profileFirstText)"; 681 + "?profileFirstText)"
682 ;
696 683
697 dbcon.Close(); 684 dbcon.Close();
698 dbcon.Open(); 685 dbcon.Open();
@@ -719,6 +706,7 @@ namespace OpenSim.Data.MySQL
719 } 706 }
720 } 707 }
721 } 708 }
709 dbcon.Close();
722 } 710 }
723 } 711 }
724 catch (Exception e) 712 catch (Exception e)
@@ -733,15 +721,10 @@ namespace OpenSim.Data.MySQL
733 721
734 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result) 722 public bool UpdateAvatarProperties(ref UserProfileProperties props, ref string result)
735 { 723 {
736 string query = string.Empty; 724 const string query = "UPDATE userprofile SET profileURL=?profileURL,"
737 725 + "profileImage=?image, profileAboutText=?abouttext,"
738 query += "UPDATE userprofile SET "; 726 + "profileFirstImage=?firstlifeimage, profileFirstText=?firstlifetext "
739 query += "profileURL=?profileURL, "; 727 + "WHERE useruuid=?uuid";
740 query += "profileImage=?image, ";
741 query += "profileAboutText=?abouttext,";
742 query += "profileFirstImage=?firstlifeimage,";
743 query += "profileFirstText=?firstlifetext ";
744 query += "WHERE useruuid=?uuid";
745 728
746 try 729 try
747 { 730 {
@@ -759,6 +742,7 @@ namespace OpenSim.Data.MySQL
759 742
760 cmd.ExecuteNonQuery(); 743 cmd.ExecuteNonQuery();
761 } 744 }
745 dbcon.Close();
762 } 746 }
763 } 747 }
764 catch (Exception e) 748 catch (Exception e)
@@ -775,15 +759,13 @@ namespace OpenSim.Data.MySQL
775 #region Avatar Interests 759 #region Avatar Interests
776 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result) 760 public bool UpdateAvatarInterests(UserProfileProperties up, ref string result)
777 { 761 {
778 string query = string.Empty; 762 const string query = "UPDATE userprofile SET "
779 763 + "profileWantToMask=?WantMask, "
780 query += "UPDATE userprofile SET "; 764 + "profileWantToText=?WantText,"
781 query += "profileWantToMask=?WantMask, "; 765 + "profileSkillsMask=?SkillsMask,"
782 query += "profileWantToText=?WantText,"; 766 + "profileSkillsText=?SkillsText, "
783 query += "profileSkillsMask=?SkillsMask,"; 767 + "profileLanguages=?Languages "
784 query += "profileSkillsText=?SkillsText, "; 768 + "WHERE useruuid=?uuid";
785 query += "profileLanguages=?Languages ";
786 query += "WHERE useruuid=?uuid";
787 769
788 try 770 try
789 { 771 {
@@ -817,18 +799,17 @@ namespace OpenSim.Data.MySQL
817 public OSDArray GetUserImageAssets(UUID avatarId) 799 public OSDArray GetUserImageAssets(UUID avatarId)
818 { 800 {
819 OSDArray data = new OSDArray(); 801 OSDArray data = new OSDArray();
820 string query = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id"; 802 const string queryA = "SELECT `snapshotuuid` FROM {0} WHERE `creatoruuid` = ?Id";
821 803
822 // Get classified image assets 804 // Get classified image assets
823 805
824
825 try 806 try
826 { 807 {
827 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString)) 808 using (MySqlConnection dbcon = new MySqlConnection(ConnectionString))
828 { 809 {
829 dbcon.Open(); 810 dbcon.Open();
830 811
831 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`classifieds`"), dbcon)) 812 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`classifieds`"), dbcon))
832 { 813 {
833 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 814 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
834 815
@@ -847,7 +828,7 @@ namespace OpenSim.Data.MySQL
847 dbcon.Close(); 828 dbcon.Close();
848 dbcon.Open(); 829 dbcon.Open();
849 830
850 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 831 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryA,"`userpicks`"), dbcon))
851 { 832 {
852 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 833 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
853 834
@@ -866,9 +847,9 @@ namespace OpenSim.Data.MySQL
866 dbcon.Close(); 847 dbcon.Close();
867 dbcon.Open(); 848 dbcon.Open();
868 849
869 query = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id"; 850 const string queryB = "SELECT `profileImage`, `profileFirstImage` FROM `userprofile` WHERE `useruuid` = ?Id";
870 851
871 using (MySqlCommand cmd = new MySqlCommand(string.Format (query,"`userpicks`"), dbcon)) 852 using (MySqlCommand cmd = new MySqlCommand(string.Format (queryB,"`userpicks`"), dbcon))
872 { 853 {
873 cmd.Parameters.AddWithValue("?Id", avatarId.ToString()); 854 cmd.Parameters.AddWithValue("?Id", avatarId.ToString());
874 855
@@ -884,6 +865,7 @@ namespace OpenSim.Data.MySQL
884 } 865 }
885 } 866 }
886 } 867 }
868 dbcon.Close();
887 } 869 }
888 } 870 }
889 catch (Exception e) 871 catch (Exception e)
@@ -897,11 +879,7 @@ namespace OpenSim.Data.MySQL
897 #region User Preferences 879 #region User Preferences
898 public bool GetUserPreferences(ref UserPreferences pref, ref string result) 880 public bool GetUserPreferences(ref UserPreferences pref, ref string result)
899 { 881 {
900 string query = string.Empty; 882 const string query = "SELECT imviaemail,visible,email FROM usersettings WHERE useruuid = ?Id";
901
902 query += "SELECT imviaemail,visible,email FROM ";
903 query += "usersettings WHERE ";
904 query += "useruuid = ?Id";
905 883
906 try 884 try
907 { 885 {
@@ -925,10 +903,9 @@ namespace OpenSim.Data.MySQL
925 dbcon.Close(); 903 dbcon.Close();
926 dbcon.Open(); 904 dbcon.Open();
927 905
928 query = "INSERT INTO usersettings VALUES "; 906 const string queryB = "INSERT INTO usersettings VALUES (?uuid,'false','false', ?Email)";
929 query += "(?uuid,'false','false', ?Email)";
930 907
931 using (MySqlCommand put = new MySqlCommand(query, dbcon)) 908 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
932 { 909 {
933 910
934 put.Parameters.AddWithValue("?Email", pref.EMail); 911 put.Parameters.AddWithValue("?Email", pref.EMail);
@@ -939,6 +916,7 @@ namespace OpenSim.Data.MySQL
939 } 916 }
940 } 917 }
941 } 918 }
919 dbcon.Close();
942 } 920 }
943 } 921 }
944 catch (Exception e) 922 catch (Exception e)
@@ -953,13 +931,9 @@ namespace OpenSim.Data.MySQL
953 931
954 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result) 932 public bool UpdateUserPreferences(ref UserPreferences pref, ref string result)
955 { 933 {
956 string query = string.Empty; 934 const string query = "UPDATE usersettings SET imviaemail=?ImViaEmail,"
957 935 + "visible=?Visible, email=?EMail "
958 query += "UPDATE usersettings SET "; 936 + "WHERE useruuid=?uuid";
959 query += "imviaemail=?ImViaEmail, ";
960 query += "visible=?Visible, ";
961 query += "email=?EMail ";
962 query += "WHERE useruuid=?uuid";
963 937
964 try 938 try
965 { 939 {
@@ -975,6 +949,7 @@ namespace OpenSim.Data.MySQL
975 949
976 cmd.ExecuteNonQuery(); 950 cmd.ExecuteNonQuery();
977 } 951 }
952 dbcon.Close();
978 } 953 }
979 } 954 }
980 catch (Exception e) 955 catch (Exception e)
@@ -991,11 +966,7 @@ namespace OpenSim.Data.MySQL
991 #region Integration 966 #region Integration
992 public bool GetUserAppData(ref UserAppData props, ref string result) 967 public bool GetUserAppData(ref UserAppData props, ref string result)
993 { 968 {
994 string query = string.Empty; 969 const string query = "SELECT * FROM `userdata` WHERE UserId = ?Id AND TagId = ?TagId";
995
996 query += "SELECT * FROM `userdata` WHERE ";
997 query += "UserId = ?Id AND ";
998 query += "TagId = ?TagId";
999 970
1000 try 971 try
1001 { 972 {
@@ -1017,13 +988,8 @@ namespace OpenSim.Data.MySQL
1017 } 988 }
1018 else 989 else
1019 { 990 {
1020 query += "INSERT INTO userdata VALUES ( "; 991 const string queryB = "INSERT INTO userdata VALUES (?UserId, ?TagId, ?DataKey, ?DataVal)";
1021 query += "?UserId,"; 992 using (MySqlCommand put = new MySqlCommand(queryB, dbcon))
1022 query += "?TagId,";
1023 query += "?DataKey,";
1024 query += "?DataVal) ";
1025
1026 using (MySqlCommand put = new MySqlCommand(query, dbcon))
1027 { 993 {
1028 put.Parameters.AddWithValue("?UserId", props.UserId.ToString()); 994 put.Parameters.AddWithValue("?UserId", props.UserId.ToString());
1029 put.Parameters.AddWithValue("?TagId", props.TagId.ToString()); 995 put.Parameters.AddWithValue("?TagId", props.TagId.ToString());
@@ -1035,6 +1001,7 @@ namespace OpenSim.Data.MySQL
1035 } 1001 }
1036 } 1002 }
1037 } 1003 }
1004 dbcon.Close();
1038 } 1005 }
1039 } 1006 }
1040 catch (Exception e) 1007 catch (Exception e)
@@ -1049,14 +1016,7 @@ namespace OpenSim.Data.MySQL
1049 1016
1050 public bool SetUserAppData(UserAppData props, ref string result) 1017 public bool SetUserAppData(UserAppData props, ref string result)
1051 { 1018 {
1052 string query = string.Empty; 1019 const string query = "UPDATE userdata SET TagId = ?TagId, DataKey = ?DataKey, DataVal = ?DataVal WHERE UserId = ?UserId AND TagId = ?TagId";
1053
1054 query += "UPDATE userdata SET ";
1055 query += "TagId = ?TagId, ";
1056 query += "DataKey = ?DataKey, ";
1057 query += "DataVal = ?DataVal WHERE ";
1058 query += "UserId = ?UserId AND ";
1059 query += "TagId = ?TagId";
1060 1020
1061 try 1021 try
1062 { 1022 {
@@ -1072,6 +1032,7 @@ namespace OpenSim.Data.MySQL
1072 1032
1073 cmd.ExecuteNonQuery(); 1033 cmd.ExecuteNonQuery();
1074 } 1034 }
1035 dbcon.Close();
1075 } 1036 }
1076 } 1037 }
1077 catch (Exception e) 1038 catch (Exception e)
diff --git a/OpenSim/Data/MySQL/MySQLXAssetData.cs b/OpenSim/Data/MySQL/MySQLXAssetData.cs
index 2c6acde..9f9c9cf 100644
--- a/OpenSim/Data/MySQL/MySQLXAssetData.cs
+++ b/OpenSim/Data/MySQL/MySQLXAssetData.cs
@@ -97,6 +97,7 @@ namespace OpenSim.Data.MySQL
97 dbcon.Open(); 97 dbcon.Open();
98 Migration m = new Migration(dbcon, Assembly, "XAssetStore"); 98 Migration m = new Migration(dbcon, Assembly, "XAssetStore");
99 m.Update(); 99 m.Update();
100 dbcon.Close();
100 } 101 }
101 } 102 }
102 103
@@ -130,6 +131,7 @@ namespace OpenSim.Data.MySQL
130// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID); 131// m_log.DebugFormat("[MYSQL XASSET DATA]: Looking for asset {0}", assetID);
131 132
132 AssetBase asset = null; 133 AssetBase asset = null;
134 int accessTime = 0;
133 135
134 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) 136 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
135 { 137 {
@@ -140,7 +142,6 @@ namespace OpenSim.Data.MySQL
140 dbcon)) 142 dbcon))
141 { 143 {
142 cmd.Parameters.AddWithValue("?ID", assetID.ToString()); 144 cmd.Parameters.AddWithValue("?ID", assetID.ToString());
143
144 try 145 try
145 { 146 {
146 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow)) 147 using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
@@ -159,23 +160,7 @@ namespace OpenSim.Data.MySQL
159 160
160 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]); 161 asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
161 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]); 162 asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
162 163 accessTime = (int)dbReader["AccessTime"];
163 if (m_enableCompression)
164 {
165 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress))
166 {
167 MemoryStream outputStream = new MemoryStream();
168 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue);
169// int compressedLength = asset.Data.Length;
170 asset.Data = outputStream.ToArray();
171
172// m_log.DebugFormat(
173// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
174// asset.ID, asset.Name, asset.Data.Length, compressedLength);
175 }
176 }
177
178 UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
179 } 164 }
180 } 165 }
181 } 166 }
@@ -184,9 +169,38 @@ namespace OpenSim.Data.MySQL
184 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e); 169 m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
185 } 170 }
186 } 171 }
172 dbcon.Close();
187 } 173 }
188 174
189 return asset; 175 if(asset == null)
176 return asset;
177
178 if(accessTime > 0)
179 {
180 try
181 {
182 UpdateAccessTime(asset.Metadata, accessTime);
183 }
184 catch { }
185 }
186
187 if (m_enableCompression && asset.Data != null)
188 {
189 using(MemoryStream ms = new MemoryStream(asset.Data))
190 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
191 {
192 using(MemoryStream outputStream = new MemoryStream())
193 {
194 decompressionStream.CopyTo(outputStream, int.MaxValue);
195// int compressedLength = asset.Data.Length;
196 asset.Data = outputStream.ToArray();
197 }
198// m_log.DebugFormat(
199// "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
200// asset.ID, asset.Name, asset.Data.Length, compressedLength);
201 }
202 }
203 return asset;
190 } 204 }
191 205
192 /// <summary> 206 /// <summary>
@@ -303,6 +317,7 @@ namespace OpenSim.Data.MySQL
303 317
304 transaction.Commit(); 318 transaction.Commit();
305 } 319 }
320 dbcon.Close();
306 } 321 }
307 } 322 }
308 323
@@ -344,6 +359,7 @@ namespace OpenSim.Data.MySQL
344 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}", 359 "[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
345 assetMetadata.ID, assetMetadata.Name); 360 assetMetadata.ID, assetMetadata.Name);
346 } 361 }
362 dbcon.Close();
347 } 363 }
348 } 364 }
349 365
@@ -474,6 +490,7 @@ namespace OpenSim.Data.MySQL
474 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString()); 490 m_log.Error("[XASSETS DB]: MySql failure fetching asset set" + Environment.NewLine + e.ToString());
475 } 491 }
476 } 492 }
493 dbcon.Close();
477 } 494 }
478 495
479 return retList; 496 return retList;
@@ -492,9 +509,9 @@ namespace OpenSim.Data.MySQL
492 cmd.Parameters.AddWithValue("?ID", id); 509 cmd.Parameters.AddWithValue("?ID", id);
493 cmd.ExecuteNonQuery(); 510 cmd.ExecuteNonQuery();
494 } 511 }
495
496 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we 512 // TODO: How do we deal with data from deleted assets? Probably not easily reapable unless we
497 // keep a reference count (?) 513 // keep a reference count (?)
514 dbcon.Close();
498 } 515 }
499 516
500 return true; 517 return true;
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index 4e41fec..5019994 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -328,7 +328,6 @@ namespace OpenSim.Data.MySQL
328 { 328 {
329 return false; 329 return false;
330 } 330 }
331 cmd.Dispose();
332 } 331 }
333 332
334 dbcon.Close(); 333 dbcon.Close();
diff --git a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
index 1a49900..6ec8914 100644
--- a/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
+++ b/OpenSim/Data/MySQL/Resources/os_groups_Store.migrations
@@ -18,7 +18,7 @@ CREATE TABLE `os_groups_groups` (
18 PRIMARY KEY (`GroupID`), 18 PRIMARY KEY (`GroupID`),
19 UNIQUE KEY `Name` (`Name`), 19 UNIQUE KEY `Name` (`Name`),
20 FULLTEXT KEY `Name_2` (`Name`) 20 FULLTEXT KEY `Name_2` (`Name`)
21) ENGINE=InnoDB; 21) ENGINE=MyISAM;
22 22
23 23
24CREATE TABLE `os_groups_membership` ( 24CREATE TABLE `os_groups_membership` (
diff --git a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
index 6e88489..1798d20 100644
--- a/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLXAssetData.cs
@@ -173,16 +173,18 @@ namespace OpenSim.Data.PGSQL
173 173
174 if (m_enableCompression) 174 if (m_enableCompression)
175 { 175 {
176 using (GZipStream decompressionStream = new GZipStream(new MemoryStream(asset.Data), CompressionMode.Decompress)) 176 using(MemoryStream ms = new MemoryStream(asset.Data))
177 using(GZipStream decompressionStream = new GZipStream(ms, CompressionMode.Decompress))
177 { 178 {
178 MemoryStream outputStream = new MemoryStream(); 179 using(MemoryStream outputStream = new MemoryStream())
179 WebUtil.CopyStream(decompressionStream, outputStream, int.MaxValue); 180 {
180 // int compressedLength = asset.Data.Length; 181 decompressionStream.CopyTo(outputStream,int.MaxValue);
181 asset.Data = outputStream.ToArray(); 182 // int compressedLength = asset.Data.Length;
182 183 asset.Data = outputStream.ToArray();
183 // m_log.DebugFormat( 184 }
184 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}", 185 // m_log.DebugFormat(
185 // asset.ID, asset.Name, asset.Data.Length, compressedLength); 186 // "[XASSET DB]: Decompressed {0} {1} to {2} bytes from {3}",
187 // asset.ID, asset.Name, asset.Data.Length, compressedLength);
186 } 188 }
187 } 189 }
188 190
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 516604a..ec3805f 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -529,7 +529,7 @@ namespace OpenSim.Framework.Servers.HttpServer
529 if (psEvArgs.Request != null) 529 if (psEvArgs.Request != null)
530 { 530 {
531 OSHttpRequest req = new OSHttpRequest(context, request); 531 OSHttpRequest req = new OSHttpRequest(context, request);
532 string requestBody = String.Empty; 532 string requestBody;
533 Encoding encoding = Encoding.UTF8; 533 Encoding encoding = Encoding.UTF8;
534 using(StreamReader reader = new StreamReader(req.InputStream, encoding)) 534 using(StreamReader reader = new StreamReader(req.InputStream, encoding))
535 requestBody = reader.ReadToEnd(); 535 requestBody = reader.ReadToEnd();
@@ -695,7 +695,8 @@ namespace OpenSim.Framework.Servers.HttpServer
695 { 695 {
696 //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler"); 696 //m_log.Debug("[BASE HTTP SERVER]: Found Caps based HTTP Handler");
697 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler; 697 IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
698 string requestBody = String.Empty; 698
699 string requestBody;
699 Encoding encoding = Encoding.UTF8; 700 Encoding encoding = Encoding.UTF8;
700 using(StreamReader reader = new StreamReader(request.InputStream, encoding)) 701 using(StreamReader reader = new StreamReader(request.InputStream, encoding))
701 requestBody = reader.ReadToEnd(); 702 requestBody = reader.ReadToEnd();
@@ -814,6 +815,8 @@ namespace OpenSim.Framework.Servers.HttpServer
814 } 815 }
815 } 816 }
816 817
818 request.InputStream.Dispose();
819
817 if (buffer != null) 820 if (buffer != null)
818 { 821 {
819 if (WebUtil.DebugLevel >= 5) 822 if (WebUtil.DebugLevel >= 5)
@@ -1119,7 +1122,7 @@ namespace OpenSim.Framework.Servers.HttpServer
1119 { 1122 {
1120 String requestBody; 1123 String requestBody;
1121 1124
1122 Stream requestStream = request.InputStream; 1125 Stream requestStream = Util.Copy(request.InputStream);
1123 Stream innerStream = null; 1126 Stream innerStream = null;
1124 try 1127 try
1125 { 1128 {
@@ -1130,10 +1133,9 @@ namespace OpenSim.Framework.Servers.HttpServer
1130 } 1133 }
1131 1134
1132 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8)) 1135 using (StreamReader reader = new StreamReader(requestStream, Encoding.UTF8))
1133 {
1134 requestBody = reader.ReadToEnd(); 1136 requestBody = reader.ReadToEnd();
1137
1135 } 1138 }
1136 }
1137 finally 1139 finally
1138 { 1140 {
1139 if (innerStream != null && innerStream.CanRead) 1141 if (innerStream != null && innerStream.CanRead)
@@ -1396,13 +1398,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1396 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); 1398 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
1397 Stream requestStream = request.InputStream; 1399 Stream requestStream = request.InputStream;
1398 1400
1399 string requestBody = string.Empty; 1401 string requestBody;
1400 Encoding encoding = Encoding.UTF8; 1402 Encoding encoding = Encoding.UTF8;
1401 using(StreamReader reader = new StreamReader(requestStream,encoding)) 1403 using(StreamReader reader = new StreamReader(requestStream, encoding))
1402 requestBody = reader.ReadToEnd(); 1404 requestBody= reader.ReadToEnd();
1403
1404 if(requestStream.CanRead)
1405 requestStream.Close();
1406 1405
1407 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody); 1406 //m_log.DebugFormat("[OGP]: {0}:{1}", request.RawUrl, requestBody);
1408 1407
@@ -1725,12 +1724,10 @@ namespace OpenSim.Framework.Servers.HttpServer
1725 byte[] buffer; 1724 byte[] buffer;
1726 1725
1727 Stream requestStream = request.InputStream; 1726 Stream requestStream = request.InputStream;
1728 string requestBody = string.Empty; 1727 string requestBody;
1729 Encoding encoding = Encoding.UTF8; 1728 Encoding encoding = Encoding.UTF8;
1730 using(StreamReader reader = new StreamReader(requestStream,encoding)) 1729 using(StreamReader reader = new StreamReader(requestStream, encoding))
1731 requestBody = reader.ReadToEnd(); 1730 requestBody = reader.ReadToEnd();
1732 if(requestStream.CanRead)
1733 requestStream.Close();
1734 1731
1735 Hashtable keysvals = new Hashtable(); 1732 Hashtable keysvals = new Hashtable();
1736 Hashtable headervals = new Hashtable(); 1733 Hashtable headervals = new Hashtable();
@@ -2269,7 +2266,7 @@ namespace OpenSim.Framework.Servers.HttpServer
2269 string file = Path.Combine(".", "http_500.html"); 2266 string file = Path.Combine(".", "http_500.html");
2270 if (!File.Exists(file)) 2267 if (!File.Exists(file))
2271 return getDefaultHTTP500(); 2268 return getDefaultHTTP500();
2272 string result = string.Empty; 2269 string result;
2273 using(StreamReader sr = File.OpenText(file)) 2270 using(StreamReader sr = File.OpenText(file))
2274 result = sr.ReadToEnd(); 2271 result = sr.ReadToEnd();
2275 return result; 2272 return result;
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
index 0305dee..dfc2715 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
@@ -50,11 +50,10 @@ namespace OpenSim.Framework.Servers.HttpServer
50 50
51 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 51 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
52 { 52 {
53 string requestBody;
53 Encoding encoding = Encoding.UTF8; 54 Encoding encoding = Encoding.UTF8;
54 StreamReader streamReader = new StreamReader(request, encoding); 55 using(StreamReader streamReader = new StreamReader(request,encoding))
55 56 requestBody = streamReader.ReadToEnd();
56 string requestBody = streamReader.ReadToEnd();
57 streamReader.Close();
58 57
59 string param = GetParam(path); 58 string param = GetParam(path);
60 string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse); 59 string responseString = m_restMethod(requestBody, path, param, httpRequest, httpResponse);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
index b3e3ac3..e8387e3 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
@@ -185,8 +185,9 @@ namespace OpenSim.Region.ClientStack.Linden
185 185
186 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 186 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
187 { 187 {
188 StreamReader reader = new StreamReader(request); 188 string message;
189 string message = reader.ReadToEnd(); 189 using(StreamReader reader = new StreamReader(request))
190 message = reader.ReadToEnd();
190 191
191 OSD osd = OSDParser.DeserializeLLSDXml(message); 192 OSD osd = OSDParser.DeserializeLLSDXml(message);
192 193
diff --git a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
index 27e84b0..cfa9581 100644
--- a/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/BakedTextures/XBakesModule.cs
@@ -216,6 +216,8 @@ namespace OpenSim.Region.CoreModules.Avatar.BakedTextures
216 rc.Request(reqStream, m_Auth); 216 rc.Request(reqStream, m_Auth);
217 m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId); 217 m_log.DebugFormat("[XBakes]: stored {0} textures for user {1}", numberWears, agentId);
218 } 218 }
219 if(reqStream != null)
220 reqStream.Dispose();
219 }, null, "XBakesModule.Store" 221 }, null, "XBakesModule.Store"
220 ); 222 );
221 } 223 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
index 81aa882..091b197 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -65,9 +65,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
65 protected override byte[] ProcessRequest( 65 protected override byte[] ProcessRequest(
66 string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 66 string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
67 { 67 {
68 StreamReader sr = new StreamReader(requestData); 68 string body;
69 string body = sr.ReadToEnd(); 69 using(StreamReader sr = new StreamReader(requestData))
70 sr.Close(); 70 body = sr.ReadToEnd();
71
71 body = body.Trim(); 72 body = body.Trim();
72 73
73 //m_log.DebugFormat("[XXX]: query String: {0}", body); 74 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
index 924a1a3..2c74c0e 100644
--- a/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/ServiceThrottle/ServiceThrottleModule.cs
@@ -119,7 +119,15 @@ namespace OpenSim.Region.CoreModules.Framework
119 if(!client.IsActive) 119 if(!client.IsActive)
120 return; 120 return;
121 121
122 GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, regionID); 122 if(m_scenes.Count == 0)
123 return;
124
125 Scene baseScene = m_scenes[0];
126
127 if(baseScene == null || baseScene.ShuttingDown)
128 return;
129
130 GridRegion r = baseScene.GridService.GetRegionByUUID(UUID.Zero, regionID);
123 131
124 if(!client.IsActive) 132 if(!client.IsActive)
125 return; 133 return;
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
index 7ab92d1..5eda8ab 100644
--- a/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/EstateRequestHandler.cs
@@ -60,9 +60,10 @@ namespace OpenSim.Region.CoreModules.World.Estate
60 protected override byte[] ProcessRequest(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 string body;
64 string body = sr.ReadToEnd(); 64 using(StreamReader sr = new StreamReader(requestData))
65 sr.Close(); 65 body = sr.ReadToEnd();
66
66 body = body.Trim(); 67 body = body.Trim();
67 68
68 // m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body); 69 // m_log.DebugFormat("[XESTATE HANDLER]: query String: {0}", body);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index c0de3d9..a5dc0ad 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -460,9 +460,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
460 460
461 if (resp.ContentLength > 0) 461 if (resp.ContentLength > 0)
462 { 462 {
463 StreamReader content = new StreamReader(resp.GetResponseStream()); 463 using(StreamReader content = new StreamReader(resp.GetResponseStream()))
464 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd()); 464 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
465 content.Close();
466 } 465 }
467 } 466 }
468 } 467 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index d52a1d5..65d50bb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -901,7 +901,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
901 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); 901 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
902 902
903 // Update the founder with new group information. 903 // Update the founder with new group information.
904 SendAgentGroupDataUpdate(remoteClient, false); 904 SendAgentGroupDataUpdate(remoteClient, true);
905 905
906 return groupID; 906 return groupID;
907 } 907 }
@@ -1520,6 +1520,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1520 lastname, activeGroupPowers, activeGroupName, 1520 lastname, activeGroupPowers, activeGroupName,
1521 activeGroupTitle); 1521 activeGroupTitle);
1522 1522
1523
1523 if (tellOthers) 1524 if (tellOthers)
1524 SendScenePresenceUpdate(agentID, activeGroupTitle); 1525 SendScenePresenceUpdate(agentID, activeGroupTitle);
1525 1526
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index d3ea7e2..4f03cf4 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -82,11 +82,11 @@ namespace OpenSim.Server.Handlers.Authentication
82 switch (p[0]) 82 switch (p[0])
83 { 83 {
84 case "plain": 84 case "plain":
85 StreamReader sr = new StreamReader(request); 85 string body;
86 string body = sr.ReadToEnd(); 86 using(StreamReader sr = new StreamReader(request))
87 sr.Close(); 87 body = sr.ReadToEnd();
88
89 return DoPlainMethods(body); 88 return DoPlainMethods(body);
89
90 case "crypt": 90 case "crypt":
91 byte[] buffer = new byte[request.Length]; 91 byte[] buffer = new byte[request.Length];
92 long length = request.Length; 92 long length = request.Length;
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
index a6605a1..254b82f 100644
--- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
@@ -222,7 +222,10 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
222 222
223 try 223 try
224 { 224 {
225 NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd()); 225 string forPost;
226 using(StreamReader sr = new StreamReader(httpRequest.InputStream))
227 forPost = sr.ReadToEnd();
228 NameValueCollection postQuery = HttpUtility.ParseQueryString(forPost);
226 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query); 229 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query);
227 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery); 230 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery);
228 231
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
index 69c1a89..b8fdacf 100644
--- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.Avatar
60 protected override byte[] ProcessRequest(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 string body;
64 string body = sr.ReadToEnd(); 64 using(StreamReader sr = new StreamReader(requestData))
65 sr.Close(); 65 body = sr.ReadToEnd();
66 body = body.Trim(); 66 body = body.Trim();
67 67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body); 68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
index 24f63d9..d16000d 100644
--- a/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
+++ b/OpenSim/Server/Handlers/BakedTextures/XBakesPostHandler.cs
@@ -65,10 +65,8 @@ namespace OpenSim.Server.Handlers.BakedTextures
65 return new byte[0]; 65 return new byte[0];
66 } 66 }
67 67
68 StreamReader sr = new StreamReader(request); 68 using(StreamReader sr = new StreamReader(request))
69 69 m_BakesService.Store(p[0],sr.ReadToEnd());
70 m_BakesService.Store(p[0], sr.ReadToEnd());
71 sr.Close();
72 70
73 return new byte[0]; 71 return new byte[0];
74 } 72 }
diff --git a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
index e0c2810..b7558ec 100644
--- a/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
+++ b/OpenSim/Server/Handlers/Estate/EstateDataRobustConnector.cs
@@ -282,9 +282,10 @@ namespace OpenSim.Server.Handlers
282 // /estates/estate/?eid=int&region=uuid 282 // /estates/estate/?eid=int&region=uuid
283 if ("estate".Equals(resource)) 283 if ("estate".Equals(resource))
284 { 284 {
285 StreamReader sr = new StreamReader(request); 285 string body;
286 string body = sr.ReadToEnd(); 286 using(StreamReader sr = new StreamReader(request))
287 sr.Close(); 287 body = sr.ReadToEnd();
288
288 body = body.Trim(); 289 body = body.Trim();
289 290
290 Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body); 291 Dictionary<string, object> requestData = ServerUtils.ParseQueryString(body);
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
index 3aab30b..d6668ab 100644
--- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
@@ -61,9 +61,9 @@ namespace OpenSim.Server.Handlers.Friends
61 protected override byte[] ProcessRequest(string path, Stream requestData, 61 protected override byte[] ProcessRequest(string path, Stream requestData,
62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
63 { 63 {
64 StreamReader sr = new StreamReader(requestData); 64 string body;
65 string body = sr.ReadToEnd(); 65 using(StreamReader sr = new StreamReader(requestData))
66 sr.Close(); 66 body = sr.ReadToEnd();
67 body = body.Trim(); 67 body = body.Trim();
68 68
69 //m_log.DebugFormat("[XXX]: query String: {0}", body); 69 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index f51c4ee..44d4654 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -65,9 +65,9 @@ namespace OpenSim.Server.Handlers.Grid
65 protected override byte[] ProcessRequest(string path, Stream requestData, 65 protected override byte[] ProcessRequest(string path, Stream requestData,
66 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 66 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
67 { 67 {
68 StreamReader sr = new StreamReader(requestData); 68 string body;
69 string body = sr.ReadToEnd(); 69 using(StreamReader sr = new StreamReader(requestData))
70 sr.Close(); 70 body = sr.ReadToEnd();
71 body = body.Trim(); 71 body = body.Trim();
72 72
73 //m_log.DebugFormat("[XXX]: query String: {0}", body); 73 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
index 8806c2c..1f691d6 100644
--- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
@@ -60,9 +60,9 @@ namespace OpenSim.Server.Handlers.GridUser
60 protected override byte[] ProcessRequest(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 string body;
64 string body = sr.ReadToEnd(); 64 using(StreamReader sr = new StreamReader(requestData))
65 sr.Close(); 65 body = sr.ReadToEnd();
66 body = body.Trim(); 66 body = body.Trim();
67 67
68 //m_log.DebugFormat("[XXX]: query String: {0}", body); 68 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index 8116050..fc1a77d 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -71,9 +71,9 @@ namespace OpenSim.Server.Handlers.Hypergrid
71 protected override byte[] ProcessRequest(string path, Stream requestData, 71 protected override byte[] ProcessRequest(string path, Stream requestData,
72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
73 { 73 {
74 StreamReader sr = new StreamReader(requestData); 74 string body;
75 string body = sr.ReadToEnd(); 75 using(StreamReader sr = new StreamReader(requestData))
76 sr.Close(); 76 body = sr.ReadToEnd();
77 body = body.Trim(); 77 body = body.Trim();
78 78
79 //m_log.DebugFormat("[XXX]: query String: {0}", body); 79 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 4400395..742d1a0 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -95,9 +95,9 @@ namespace OpenSim.Server.Handlers.Inventory
95 protected override byte[] ProcessRequest(string path, Stream requestData, 95 protected override byte[] ProcessRequest(string path, Stream requestData,
96 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 96 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
97 { 97 {
98 StreamReader sr = new StreamReader(requestData); 98 string body;
99 string body = sr.ReadToEnd(); 99 using(StreamReader sr = new StreamReader(requestData))
100 sr.Close(); 100 body = sr.ReadToEnd();
101 body = body.Trim(); 101 body = body.Trim();
102 102
103 //m_log.DebugFormat("[XXX]: query String: {0}", body); 103 //m_log.DebugFormat("[XXX]: query String: {0}", body);
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
index 7611f53..bfd73a2 100644
--- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
@@ -104,9 +104,9 @@ namespace OpenSim.Server.Handlers.MapImage
104 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 104 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
105 { 105 {
106// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 106// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
107 StreamReader sr = new StreamReader(requestData); 107 string body;
108 string body = sr.ReadToEnd(); 108 using(StreamReader sr = new StreamReader(requestData))
109 sr.Close(); 109 body = sr.ReadToEnd();
110 body = body.Trim(); 110 body = body.Trim();
111 111
112 try 112 try
diff --git a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
index f292b95..8a3875d 100644
--- a/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapRemoveServerConnector.cs
@@ -102,9 +102,9 @@ namespace OpenSim.Server.Handlers.MapImage
102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
103 { 103 {
104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
105 StreamReader sr = new StreamReader(requestData); 105 string body;
106 string body = sr.ReadToEnd(); 106 using(StreamReader sr = new StreamReader(requestData))
107 sr.Close(); 107 body = sr.ReadToEnd();
108 body = body.Trim(); 108 body = body.Trim();
109 109
110 try 110 try
@@ -215,13 +215,16 @@ namespace OpenSim.Server.Handlers.MapImage
215 215
216 private byte[] DocToBytes(XmlDocument doc) 216 private byte[] DocToBytes(XmlDocument doc)
217 { 217 {
218 MemoryStream ms = new MemoryStream(); 218 using(MemoryStream ms = new MemoryStream())
219 XmlTextWriter xw = new XmlTextWriter(ms, null); 219 {
220 xw.Formatting = Formatting.Indented; 220 using(XmlTextWriter xw = new XmlTextWriter(ms,null))
221 doc.WriteTo(xw); 221 {
222 xw.Flush(); 222 xw.Formatting = Formatting.Indented;
223 223 doc.WriteTo(xw);
224 xw.Flush();
225 }
224 return ms.ToArray(); 226 return ms.ToArray();
227 }
225 } 228 }
226 229
227 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request) 230 private System.Net.IPAddress GetCallerIP(IOSHttpRequest request)
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index a02255f..bc12ef9 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -72,9 +72,9 @@ namespace OpenSim.Server.Handlers.UserAccounts
72 protected override byte[] ProcessRequest(string path, Stream requestData, 72 protected override byte[] ProcessRequest(string path, Stream requestData,
73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 73 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
74 { 74 {
75 StreamReader sr = new StreamReader(requestData); 75 string body;
76 string body = sr.ReadToEnd(); 76 using(StreamReader sr = new StreamReader(requestData))
77 sr.Close(); 77 body = sr.ReadToEnd();
78 body = body.Trim(); 78 body = body.Trim();
79 79
80 // We need to check the authorization header 80 // We need to check the authorization header
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
index 939059d..5f075ac 100644
--- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs
@@ -183,8 +183,8 @@ namespace OpenSim.Services.Connectors
183 { 183 {
184 using (StreamReader sr = new StreamReader(s)) 184 using (StreamReader sr = new StreamReader(s))
185 { 185 {
186 sr.ReadToEnd(); // just try to read
186 //reply = sr.ReadToEnd().Trim(); 187 //reply = sr.ReadToEnd().Trim();
187 sr.ReadToEnd().Trim();
188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); 188 //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply);
189 } 189 }
190 } 190 }
diff --git a/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs
new file mode 100644
index 0000000..8e2d8e6
--- /dev/null
+++ b/OpenSim/Tests/Common/Mock/TestGroupsDataPlugin.cs
@@ -0,0 +1,339 @@
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6using OpenMetaverse;
7using OpenSim.Data;
8
9namespace OpenSim.Tests.Common.Mock
10{
11 public class TestGroupsDataPlugin : IGroupsData
12 {
13 class CompositeKey
14 {
15 private readonly string _key;
16 public string Key
17 {
18 get { return _key; }
19 }
20
21 public CompositeKey(UUID _k1, string _k2)
22 {
23 _key = _k1.ToString() + _k2;
24 }
25
26 public CompositeKey(UUID _k1, string _k2, string _k3)
27 {
28 _key = _k1.ToString() + _k2 + _k3;
29 }
30
31 public override bool Equals(object obj)
32 {
33 if (obj is CompositeKey)
34 {
35 return Key == ((CompositeKey)obj).Key;
36 }
37 return false;
38 }
39
40 public override int GetHashCode()
41 {
42 return base.GetHashCode();
43 }
44
45 public override string ToString()
46 {
47 return Key;
48 }
49 }
50
51 private Dictionary<UUID, GroupData> m_Groups;
52 private Dictionary<CompositeKey, MembershipData> m_Membership;
53 private Dictionary<CompositeKey, RoleData> m_Roles;
54 private Dictionary<CompositeKey, RoleMembershipData> m_RoleMembership;
55 private Dictionary<UUID, InvitationData> m_Invites;
56 private Dictionary<UUID, NoticeData> m_Notices;
57 private Dictionary<string, PrincipalData> m_Principals;
58
59 public TestGroupsDataPlugin(string connectionString, string realm)
60 {
61 m_Groups = new Dictionary<UUID, GroupData>();
62 m_Membership = new Dictionary<CompositeKey, MembershipData>();
63 m_Roles = new Dictionary<CompositeKey, RoleData>();
64 m_RoleMembership = new Dictionary<CompositeKey, RoleMembershipData>();
65 m_Invites = new Dictionary<UUID, InvitationData>();
66 m_Notices = new Dictionary<UUID, NoticeData>();
67 m_Principals = new Dictionary<string, PrincipalData>();
68 }
69
70 #region groups table
71 public bool StoreGroup(GroupData data)
72 {
73 return false;
74 }
75
76 public GroupData RetrieveGroup(UUID groupID)
77 {
78 if (m_Groups.ContainsKey(groupID))
79 return m_Groups[groupID];
80
81 return null;
82 }
83
84 public GroupData RetrieveGroup(string name)
85 {
86 return m_Groups.Values.First(g => g.Data.ContainsKey("Name") && g.Data["Name"] == name);
87 }
88
89 public GroupData[] RetrieveGroups(string pattern)
90 {
91 if (string.IsNullOrEmpty(pattern))
92 pattern = "1";
93
94 IEnumerable<GroupData> groups = m_Groups.Values.Where(g => g.Data.ContainsKey("Name") && (g.Data["Name"].StartsWith(pattern) || g.Data["Name"].EndsWith(pattern)));
95
96 return (groups != null) ? groups.ToArray() : new GroupData[0];
97 }
98
99 public bool DeleteGroup(UUID groupID)
100 {
101 return m_Groups.Remove(groupID);
102 }
103
104 public int GroupsCount()
105 {
106 return m_Groups.Count;
107 }
108 #endregion
109
110 #region membership table
111 public MembershipData RetrieveMember(UUID groupID, string pricipalID)
112 {
113 CompositeKey dkey = new CompositeKey(groupID, pricipalID);
114 if (m_Membership.ContainsKey(dkey))
115 return m_Membership[dkey];
116
117 return null;
118 }
119
120 public MembershipData[] RetrieveMembers(UUID groupID)
121 {
122 IEnumerable<CompositeKey> keys = m_Membership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
123 return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
124 }
125
126 public MembershipData[] RetrieveMemberships(string principalID)
127 {
128 IEnumerable<CompositeKey> keys = m_Membership.Keys.Where(k => k.Key.EndsWith(principalID.ToString()));
129 return keys.Where(m_Membership.ContainsKey).Select(x => m_Membership[x]).ToArray();
130 }
131
132 public MembershipData[] RetrievePrincipalGroupMemberships(string principalID)
133 {
134 return RetrieveMemberships(principalID);
135 }
136
137 public MembershipData RetrievePrincipalGroupMembership(string principalID, UUID groupID)
138 {
139 CompositeKey dkey = new CompositeKey(groupID, principalID);
140 if (m_Membership.ContainsKey(dkey))
141 return m_Membership[dkey];
142 return null;
143 }
144
145 public bool StoreMember(MembershipData data)
146 {
147 CompositeKey dkey = new CompositeKey(data.GroupID, data.PrincipalID);
148 m_Membership[dkey] = data;
149 return true;
150 }
151
152 public bool DeleteMember(UUID groupID, string principalID)
153 {
154 CompositeKey dkey = new CompositeKey(groupID, principalID);
155 if (m_Membership.ContainsKey(dkey))
156 return m_Membership.Remove(dkey);
157
158 return false;
159 }
160
161 public int MemberCount(UUID groupID)
162 {
163 return m_Membership.Count;
164 }
165 #endregion
166
167 #region roles table
168 public bool StoreRole(RoleData data)
169 {
170 CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString());
171 m_Roles[dkey] = data;
172 return true;
173 }
174
175 public RoleData RetrieveRole(UUID groupID, UUID roleID)
176 {
177 CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
178 if (m_Roles.ContainsKey(dkey))
179 return m_Roles[dkey];
180
181 return null;
182 }
183
184 public RoleData[] RetrieveRoles(UUID groupID)
185 {
186 IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
187 return keys.Where(m_Roles.ContainsKey).Select(x => m_Roles[x]).ToArray();
188 }
189
190 public bool DeleteRole(UUID groupID, UUID roleID)
191 {
192 CompositeKey dkey = new CompositeKey(groupID, roleID.ToString());
193 if (m_Roles.ContainsKey(dkey))
194 return m_Roles.Remove(dkey);
195
196 return false;
197 }
198
199 public int RoleCount(UUID groupID)
200 {
201 return m_Roles.Count;
202 }
203 #endregion
204
205 #region rolememberhip table
206 public RoleMembershipData[] RetrieveRolesMembers(UUID groupID)
207 {
208 IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()));
209 return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
210 }
211
212 public RoleMembershipData[] RetrieveRoleMembers(UUID groupID, UUID roleID)
213 {
214 IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString() + roleID.ToString()));
215 return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
216 }
217
218 public RoleMembershipData[] RetrieveMemberRoles(UUID groupID, string principalID)
219 {
220 IEnumerable<CompositeKey> keys = m_Roles.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID));
221 return keys.Where(m_RoleMembership.ContainsKey).Select(x => m_RoleMembership[x]).ToArray();
222 }
223
224 public RoleMembershipData RetrieveRoleMember(UUID groupID, UUID roleID, string principalID)
225 {
226 CompositeKey dkey = new CompositeKey(groupID, roleID.ToString(), principalID);
227 if (m_RoleMembership.ContainsKey(dkey))
228 return m_RoleMembership[dkey];
229
230 return null;
231 }
232
233 public int RoleMemberCount(UUID groupID, UUID roleID)
234 {
235 return m_RoleMembership.Count;
236 }
237
238 public bool StoreRoleMember(RoleMembershipData data)
239 {
240 CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
241 m_RoleMembership[dkey] = data;
242 return true;
243 }
244
245 public bool DeleteRoleMember(RoleMembershipData data)
246 {
247 CompositeKey dkey = new CompositeKey(data.GroupID, data.RoleID.ToString(), data.PrincipalID);
248 if (m_RoleMembership.ContainsKey(dkey))
249 return m_RoleMembership.Remove(dkey);
250
251 return false;
252 }
253
254 public bool DeleteMemberAllRoles(UUID groupID, string principalID)
255 {
256 List<CompositeKey> keys = m_RoleMembership.Keys.Where(k => k.Key.StartsWith(groupID.ToString()) && k.Key.EndsWith(principalID)).ToList();
257 foreach (CompositeKey k in keys)
258 m_RoleMembership.Remove(k);
259 return true;
260 }
261 #endregion
262
263 #region principals table
264 public bool StorePrincipal(PrincipalData data)
265 {
266 m_Principals[data.PrincipalID] = data;
267 return true;
268 }
269
270 public PrincipalData RetrievePrincipal(string principalID)
271 {
272 if (m_Principals.ContainsKey(principalID))
273 return m_Principals[principalID];
274
275 return null;
276 }
277
278 public bool DeletePrincipal(string principalID)
279 {
280 if (m_Principals.ContainsKey(principalID))
281 return m_Principals.Remove(principalID);
282 return false;
283 }
284 #endregion
285
286 #region invites table
287 public bool StoreInvitation(InvitationData data)
288 {
289 return false;
290 }
291
292 public InvitationData RetrieveInvitation(UUID inviteID)
293 {
294 return null;
295 }
296
297 public InvitationData RetrieveInvitation(UUID groupID, string principalID)
298 {
299 return null;
300 }
301
302 public bool DeleteInvite(UUID inviteID)
303 {
304 return false;
305 }
306
307 public void DeleteOldInvites()
308 {
309 }
310 #endregion
311
312 #region notices table
313 public bool StoreNotice(NoticeData data)
314 {
315 return false;
316 }
317
318 public NoticeData RetrieveNotice(UUID noticeID)
319 {
320 return null;
321 }
322
323 public NoticeData[] RetrieveNotices(UUID groupID)
324 {
325 return new NoticeData[0];
326 }
327
328 public bool DeleteNotice(UUID noticeID)
329 {
330 return false;
331 }
332
333 public void DeleteOldNotices()
334 {
335 }
336 #endregion
337
338 }
339}
diff --git a/OpenSim/Tests/Permissions/Common.cs b/OpenSim/Tests/Permissions/Common.cs
index f93c120..4ecce38 100644
--- a/OpenSim/Tests/Permissions/Common.cs
+++ b/OpenSim/Tests/Permissions/Common.cs
@@ -72,12 +72,21 @@ namespace OpenSim.Tests.Permissions
72 IConfigSource config = new IniConfigSource(); 72 IConfigSource config = new IniConfigSource();
73 config.AddConfig("Messaging"); 73 config.AddConfig("Messaging");
74 config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule"); 74 config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
75
75 config.AddConfig("Modules"); 76 config.AddConfig("Modules");
76 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); 77 config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
78
77 config.AddConfig("InventoryService"); 79 config.AddConfig("InventoryService");
78 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService"); 80 config.Configs["InventoryService"].Set("LocalServiceModule", "OpenSim.Services.InventoryService.dll:XInventoryService");
79 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin"); 81 config.Configs["InventoryService"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestXInventoryDataPlugin");
80 82
83 config.AddConfig("Groups");
84 config.Configs["Groups"].Set("Enabled", "true");
85 config.Configs["Groups"].Set("Module", "Groups Module V2");
86 config.Configs["Groups"].Set("StorageProvider", "OpenSim.Tests.Common.dll:TestGroupsDataPlugin");
87 config.Configs["Groups"].Set("ServicesConnectorModule", "Groups Local Service Connector");
88 config.Configs["Groups"].Set("LocalService", "local");
89
81 m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config); 90 m_Scene = new SceneHelpers().SetupScene("Test", UUID.Random(), 1000, 1000, config);
82 // Add modules 91 // Add modules
83 SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule()); 92 SceneHelpers.SetupSceneModules(m_Scene, config, new DefaultPermissionsModule(), new InventoryTransferModule(), new BasicInventoryAccessModule());
diff --git a/bin/CSJ2K.dll b/bin/CSJ2K.dll
index e882e4c..238291f 100755
--- a/bin/CSJ2K.dll
+++ b/bin/CSJ2K.dll
Binary files differ