Fixed problem with MySQL: it was possible for one thread to use an incomplete list of column names if another thread was creating the list at the same time. Now this is thread-safe.
parent
c70e85a327
commit
da5fd53702
|
@ -79,14 +79,7 @@ namespace OpenSim.Data.MySQL
|
||||||
{
|
{
|
||||||
ret.PrincipalID = principalID;
|
ret.PrincipalID = principalID;
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
CheckColumnNames(result);
|
||||||
{
|
|
||||||
m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
foreach (string s in m_ColumnNames)
|
||||||
{
|
{
|
||||||
|
@ -105,6 +98,20 @@ namespace OpenSim.Data.MySQL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckColumnNames(IDataReader result)
|
||||||
|
{
|
||||||
|
if (m_ColumnNames != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<string> columnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
columnNames.Add(row["ColumnName"].ToString());
|
||||||
|
|
||||||
|
m_ColumnNames = columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Store(AuthenticationData data)
|
public bool Store(AuthenticationData data)
|
||||||
{
|
{
|
||||||
if (data.Data.ContainsKey("UUID"))
|
if (data.Data.ContainsKey("UUID"))
|
||||||
|
|
|
@ -91,15 +91,17 @@ namespace OpenSim.Data.MySQL
|
||||||
if (m_ColumnNames != null)
|
if (m_ColumnNames != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ColumnNames = new List<string>();
|
List<string> columnNames = new List<string>();
|
||||||
|
|
||||||
DataTable schemaTable = reader.GetSchemaTable();
|
DataTable schemaTable = reader.GetSchemaTable();
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
{
|
{
|
||||||
if (row["ColumnName"] != null &&
|
if (row["ColumnName"] != null &&
|
||||||
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
(!m_Fields.ContainsKey(row["ColumnName"].ToString())))
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
columnNames.Add(row["ColumnName"].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ColumnNames = columnNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual T[] Get(string field, string key)
|
public virtual T[] Get(string field, string key)
|
||||||
|
|
|
@ -162,17 +162,7 @@ namespace OpenSim.Data.MySQL
|
||||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
||||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
||||||
|
|
||||||
if (m_ColumnNames == null)
|
CheckColumnNames(result);
|
||||||
{
|
|
||||||
m_ColumnNames = new List<string>();
|
|
||||||
|
|
||||||
DataTable schemaTable = result.GetSchemaTable();
|
|
||||||
foreach (DataRow row in schemaTable.Rows)
|
|
||||||
{
|
|
||||||
if (row["ColumnName"] != null)
|
|
||||||
m_ColumnNames.Add(row["ColumnName"].ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (string s in m_ColumnNames)
|
foreach (string s in m_ColumnNames)
|
||||||
{
|
{
|
||||||
|
@ -202,6 +192,23 @@ namespace OpenSim.Data.MySQL
|
||||||
return retList;
|
return retList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckColumnNames(IDataReader result)
|
||||||
|
{
|
||||||
|
if (m_ColumnNames != null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
List<string> columnNames = new List<string>();
|
||||||
|
|
||||||
|
DataTable schemaTable = result.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
|
{
|
||||||
|
if (row["ColumnName"] != null)
|
||||||
|
columnNames.Add(row["ColumnName"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
m_ColumnNames = columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Store(RegionData data)
|
public bool Store(RegionData data)
|
||||||
{
|
{
|
||||||
if (data.Data.ContainsKey("uuid"))
|
if (data.Data.ContainsKey("uuid"))
|
||||||
|
|
Loading…
Reference in New Issue