Partial revert of "Core/DB Layer: Fix a memory leak.", mysql library related stuff. Original memory leak fix is still in place.

This commit is contained in:
Machiavelli
2012-03-26 13:33:47 +02:00
parent 70ee37f3b4
commit e960016dc4
5 changed files with 7 additions and 11 deletions
+2
View File
@@ -246,6 +246,8 @@ extern int main(int argc, char **argv)
// Initialize connection to the database
bool StartDB()
{
MySQL::Library_Init();
std::string dbstring = ConfigMgr::GetStringDefault("LoginDatabaseInfo", "");
if (dbstring.empty())
{
@@ -34,11 +34,6 @@ int DatabaseWorker::svc()
if (!m_queue)
return -1;
//! Since this is called from the worker thread itself, we can ensure
//! that thread-specific variables remain in this thread.
if (!m_conn->Open())
return -1;
SQLOperation *request = NULL;
while (1)
{
@@ -52,7 +47,5 @@ int DatabaseWorker::svc()
delete request;
}
//! Clean up thread-specific variables
m_conn->Close();
return 0;
}
@@ -77,6 +77,7 @@ class DatabaseWorkerPool
for (uint8 i = 0; i < async_threads; ++i)
{
T* t = new T(m_queue, m_connectionInfo);
res &= t->Open();
m_connections[IDX_ASYNC][i] = t;
++m_connectionCount[IDX_ASYNC];
}
@@ -110,6 +111,7 @@ class DatabaseWorkerPool
DatabaseWorker* worker = t->m_worker;
worker->wait();
delete worker;
t->Close();
}
sLog->outSQLDriver("Asynchronous connections on databasepool '%s' terminated. Proceeding with synchronous connections.", m_connectionInfo.database.c_str());
@@ -124,6 +126,7 @@ class DatabaseWorkerPool
}
delete m_queue;
sLog->outSQLDriver("All connections on databasepool %s closed.", m_connectionInfo.database.c_str());
}
@@ -68,13 +68,9 @@ MySQLConnection::~MySQLConnection()
}
mysql_close(m_Mysql);
MySQL::Thread_End();
Unlock(); /// Unlock while we die, how ironic
}
//! Can be called synchronously in DatabaseWorkerPool, in which thread-specific variables initialized in the main thread
//! are deallocated.
//! Can also be called by worker threads, in which their respective thread-specific variables are deallocated.
void MySQLConnection::Close()
{
/// Only close us if we're not operating
+2
View File
@@ -362,6 +362,8 @@ int Master::Run()
/// Initialize connection to the databases
bool Master::_StartDB()
{
MySQL::Library_Init();
sLog->SetLogDB(false);
std::string dbstring;
uint8 async_threads, synch_threads;