aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/MySQL/MySQLXInventoryData.cs
diff options
context:
space:
mode:
authorMaster ScienceSim2010-02-04 13:19:30 -0800
committerJohn Hurliman2010-02-05 18:07:59 -0800
commite1b5c612472b9d1acf47383c0bf75b555daff2e6 (patch)
tree083896698038fbdad59c2bd3adeba9b290c5ce1b /OpenSim/Data/MySQL/MySQLXInventoryData.cs
parentFixing an incorrect logging message in insertUserRow (diff)
downloadopensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.zip
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.gz
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.bz2
opensim-SC-e1b5c612472b9d1acf47383c0bf75b555daff2e6.tar.xz
Updated MySQL connection management to use the MySQL connection pooling. This should accommodate various timeout problems that exist with the current connection pool code in a more general and standard way.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs65
1 files changed, 38 insertions, 27 deletions
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index 0eebc9c..b5866cb 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -110,47 +110,58 @@ namespace OpenSim.Data.MySQL
110 110
111 public bool MoveItem(string id, string newParent) 111 public bool MoveItem(string id, string newParent)
112 { 112 {
113 MySqlCommand cmd = new MySqlCommand(); 113 using (MySqlCommand cmd = new MySqlCommand())
114 {
114 115
115 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm); 116 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
116 cmd.Parameters.AddWithValue("?ParentFolderID", newParent); 117 cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
117 cmd.Parameters.AddWithValue("?InventoryID", id); 118 cmd.Parameters.AddWithValue("?InventoryID", id);
118 119
119 return ExecuteNonQuery(cmd) == 0 ? false : true; 120 return ExecuteNonQuery(cmd) == 0 ? false : true;
121 }
120 } 122 }
121 123
122 public XInventoryItem[] GetActiveGestures(UUID principalID) 124 public XInventoryItem[] GetActiveGestures(UUID principalID)
123 { 125 {
124 MySqlCommand cmd = new MySqlCommand(); 126 using (MySqlCommand cmd = new MySqlCommand())
125 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm); 127 {
128 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
126 129
127 cmd.Parameters.AddWithValue("?uuid", principalID.ToString()); 130 cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
128 cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture); 131 cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
129 132
130 return DoQuery(cmd); 133 return DoQuery(cmd);
134 }
131 } 135 }
132 136
133 public int GetAssetPermissions(UUID principalID, UUID assetID) 137 public int GetAssetPermissions(UUID principalID, UUID assetID)
134 { 138 {
135 MySqlCommand cmd = new MySqlCommand(); 139 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
136
137 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
138 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
139 cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
140
141 IDataReader reader = ExecuteReader(cmd);
142
143 int perms = 0;
144
145 if (reader.Read())
146 { 140 {
147 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]); 141 dbcon.Open();
142
143 using (MySqlCommand cmd = new MySqlCommand())
144 {
145 cmd.Connection = dbcon;
146
147 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
148 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
149 cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
150
151 using (IDataReader reader = cmd.ExecuteReader())
152 {
153
154 int perms = 0;
155
156 if (reader.Read())
157 {
158 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
159 }
160
161 return perms;
162 }
163 }
148 } 164 }
149
150 reader.Close();
151 CloseReaderCommand(cmd);
152
153 return perms;
154 } 165 }
155 } 166 }
156} 167}