Core/DBLayer

- Store threadbundlemask internally per database pool and prevent direct access to config file post startup
- Fix threadbundlemask flag checking for ReactorRunnable, WorldRunnable
- Remove CLI threadbundlemask flag, CLI doesn´t need a seperate mysql connection nor thread
- Remove unused Character Database connection from WorldSocketMgr / ReactorRunnable
- Add proper LoginDatabase connection to RA Runnable (soon to be overhauled)

Note: still experimental and not tested for live use

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-09-03 10:52:32 +02:00
parent 277f2674ac
commit 273679c5ba
8 changed files with 62 additions and 84 deletions

View File

@@ -33,6 +33,7 @@
#include "WorldSocketMgr.h"
#include "Configuration/Config.h"
#include "Database/DatabaseEnv.h"
#include "Database/DatabaseWorkerPool.h"
#include "CliRunnable.h"
#include "Log.h"
@@ -134,9 +135,7 @@ public:
{
loopCounter = 0;
sLog.outDetail ("Ping MySQL to keep connection alive");
WorldDatabase.Query ("SELECT 1 FROM command LIMIT 1");
LoginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1");
CharacterDatabase.Query ("SELECT 1 FROM bugreport LIMIT 1");
}
}
@@ -163,6 +162,15 @@ public:
sLog.outString ("Starting Remote access listner on port %d on %s", raport, stringip.c_str ());
}
bool needInit = true;
if ((LoginDatabase.GetBundleMask() & MYSQL_BUNDLE_RA))
{
LoginDatabase.Init_MySQL_Connection();
needInit = false;
}
if (needInit)
MySQL::Thread_Init();
}
// Socket Selet time is in microseconds , not miliseconds!!
@@ -176,13 +184,18 @@ public:
h.Select (0, socketSelecttime);
checkping ();
}
if (!needInit)
LoginDatabase.End_MySQL_Connection();
else
MySQL::Thread_End();
}
else
{
while (!World::IsStopped())
{
ACE_Based::Thread::Sleep(static_cast<unsigned long> (socketSelecttime / 1000));
checkping ();
// checkping (); -- What?
}
}
}
@@ -440,6 +453,7 @@ bool Master::_StartDB()
sLog.SetLogDB(false);
std::string dbstring;
uint8 num_threads;
int32 mask;
dbstring = sConfig.GetStringDefault("WorldDatabaseInfo", "");
if (dbstring.empty())
@@ -456,8 +470,10 @@ bool Master::_StartDB()
return false;
}
mask = sConfig.GetIntDefault("WorldDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
///- Initialise the world database
if (!WorldDatabase.Open(dbstring, num_threads))
if (!WorldDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
{
sLog.outError("Cannot connect to world database %s", dbstring.c_str());
return false;
@@ -478,12 +494,15 @@ bool Master::_StartDB()
return false;
}
mask = sConfig.GetIntDefault("CharacterDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
///- Initialise the Character database
if (!CharacterDatabase.Open(dbstring, num_threads))
if (!CharacterDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
{
sLog.outError("Cannot connect to Character database %s", dbstring.c_str());
return false;
}
///- Get login database info from configuration file
dbstring = sConfig.GetStringDefault("LoginDatabaseInfo", "");
if (dbstring.empty())
@@ -500,8 +519,10 @@ bool Master::_StartDB()
return false;
}
mask = sConfig.GetIntDefault("LoginDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
///- Initialise the login database
if (!LoginDatabase.Open(dbstring, num_threads))
if (!LoginDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
{
sLog.outError("Cannot connect to login database %s", dbstring.c_str());
return false;