Fix SQLite locking and make it more fascist for now
parent
611eeb583c
commit
d761d1624b
|
@ -40,12 +40,10 @@ namespace OpenSim.Data.SQLite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SQLiteFramework
|
public class SQLiteFramework
|
||||||
{
|
{
|
||||||
protected SqliteConnection m_Connection;
|
protected Object m_lockObject = new Object();
|
||||||
|
|
||||||
protected SQLiteFramework(string connectionString)
|
protected SQLiteFramework(string connectionString)
|
||||||
{
|
{
|
||||||
//m_Connection = new SqliteConnection(connectionString);
|
|
||||||
//m_Connection.Open();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
@ -55,9 +53,13 @@ namespace OpenSim.Data.SQLite
|
||||||
//
|
//
|
||||||
protected int ExecuteNonQuery(SqliteCommand cmd)
|
protected int ExecuteNonQuery(SqliteCommand cmd)
|
||||||
{
|
{
|
||||||
lock (m_Connection)
|
lock (m_lockObject)
|
||||||
{
|
{
|
||||||
cmd.Connection = m_Connection;
|
SqliteConnection newConnection =
|
||||||
|
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
|
newConnection.Open();
|
||||||
|
|
||||||
|
cmd.Connection = newConnection;
|
||||||
Console.WriteLine("XXX " + cmd.CommandText);
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
|
|
||||||
return cmd.ExecuteNonQuery();
|
return cmd.ExecuteNonQuery();
|
||||||
|
@ -65,6 +67,8 @@ namespace OpenSim.Data.SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
protected IDataReader ExecuteReader(SqliteCommand cmd)
|
||||||
|
{
|
||||||
|
lock (m_lockObject)
|
||||||
{
|
{
|
||||||
SqliteConnection newConnection =
|
SqliteConnection newConnection =
|
||||||
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
(SqliteConnection)((ICloneable)m_Connection).Clone();
|
||||||
|
@ -74,12 +78,16 @@ namespace OpenSim.Data.SQLite
|
||||||
Console.WriteLine("XXX " + cmd.CommandText);
|
Console.WriteLine("XXX " + cmd.CommandText);
|
||||||
return cmd.ExecuteReader();
|
return cmd.ExecuteReader();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void CloseReaderCommand(SqliteCommand cmd)
|
protected void CloseReaderCommand(SqliteCommand cmd)
|
||||||
|
{
|
||||||
|
lock (m_lockObject)
|
||||||
{
|
{
|
||||||
cmd.Connection.Close();
|
cmd.Connection.Close();
|
||||||
cmd.Connection.Dispose();
|
cmd.Connection.Dispose();
|
||||||
cmd.Dispose();
|
cmd.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue