mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
More SQL fixes
Should help with some crashes Still doesn't call thread_init Still shares statements and connections between threads
This commit is contained in:
parent
18d9e77d43
commit
a58ade137d
|
@ -36,7 +36,15 @@ CSqlServer::~CSqlServer()
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (m_pResults)
|
if (m_pResults)
|
||||||
|
{
|
||||||
delete m_pResults;
|
delete m_pResults;
|
||||||
|
m_pResults = 0;
|
||||||
|
}
|
||||||
|
if (m_pStatement)
|
||||||
|
{
|
||||||
|
delete m_pStatement;
|
||||||
|
m_pStatement = 0;
|
||||||
|
}
|
||||||
if (m_pConnection)
|
if (m_pConnection)
|
||||||
{
|
{
|
||||||
delete m_pConnection;
|
delete m_pConnection;
|
||||||
|
@ -120,7 +128,7 @@ bool CSqlServer::Connect()
|
||||||
}
|
}
|
||||||
m_pConnection = m_pDriver->connect(connection_properties);
|
m_pConnection = m_pDriver->connect(connection_properties);
|
||||||
|
|
||||||
// Create Statement
|
// Create statement
|
||||||
m_pStatement = m_pConnection->createStatement();
|
m_pStatement = m_pConnection->createStatement();
|
||||||
|
|
||||||
if (m_SetUpDB)
|
if (m_SetUpDB)
|
||||||
|
@ -200,16 +208,20 @@ void CSqlServer::CreateTables()
|
||||||
|
|
||||||
void CSqlServer::executeSql(const char *pCommand)
|
void CSqlServer::executeSql(const char *pCommand)
|
||||||
{
|
{
|
||||||
|
scope_lock LockScope(&m_SqlLock);
|
||||||
m_pStatement->execute(pCommand);
|
m_pStatement->execute(pCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSqlServer::executeSqlQuery(const char *pQuery)
|
void CSqlServer::executeSqlQuery(const char *pQuery)
|
||||||
{
|
{
|
||||||
|
scope_lock LockScope(&m_SqlLock);
|
||||||
if (m_pResults)
|
if (m_pResults)
|
||||||
|
{
|
||||||
delete m_pResults;
|
delete m_pResults;
|
||||||
|
|
||||||
// set it to 0, so exceptions raised from executeQuery can not make m_pResults point to invalid memory
|
// set it to 0, so exceptions raised from executeQuery can not make m_pResults point to invalid memory
|
||||||
m_pResults = 0;
|
m_pResults = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m_pResults = m_pStatement->executeQuery(pQuery);
|
m_pResults = m_pStatement->executeQuery(pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue