aboutsummaryrefslogtreecommitdiff
path: root/src/server/worldserver
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-09-27 00:20:56 +0200
committerMachiavelli <none@none>2010-09-27 00:20:56 +0200
commita9e9a2c8848c22e4a3e3b7bab0caeca25d9ea408 (patch)
treea7c4960796d0a9a42cb1e0252d4a75c4436d1f01 /src/server/worldserver
parent894b2081b3837575bd44c71ea4ebc76008b5b5e3 (diff)
Core/DBLayer:
- DB Threading model update * Get rid of ThreadBundleMask and bundled connection * Implement configurable amount of Synch threads for databasepools * Use modulus based algorithm to check for free synchronous connections instead of previous ¨get connection by thread key or bundlemask¨ feature * Locks on mysql context objects are now managed outside the mysql query methods Fixes issue #4058 Fixes issue #4059 Introduces a ton of more issues. Use at own risk. You were warned. Really. Don´t forget to update your worldserver.conf --HG-- branch : trunk
Diffstat (limited to 'src/server/worldserver')
-rw-r--r--src/server/worldserver/Master.cpp40
-rw-r--r--src/server/worldserver/WorldThread/WorldRunnable.cpp34
-rw-r--r--src/server/worldserver/worldserver.conf.dist27
3 files changed, 23 insertions, 78 deletions
diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp
index 3dca8d3935b..bf1811523bb 100644
--- a/src/server/worldserver/Master.cpp
+++ b/src/server/worldserver/Master.cpp
@@ -163,14 +163,6 @@ public:
sLog.outString ("Starting Remote access listner on port %d on %s", raport, stringip.c_str ());
}
-
- 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!!
@@ -184,11 +176,6 @@ public:
h.Select (0, socketSelecttime);
checkping ();
}
-
- if (!needInit)
- LoginDatabase.End_MySQL_Connection();
- else
- MySQL::Thread_End();
}
else
{
@@ -452,8 +439,7 @@ bool Master::_StartDB()
{
sLog.SetLogDB(false);
std::string dbstring;
- uint8 num_threads;
- int32 mask;
+ uint8 async_threads, synch_threads;
dbstring = sConfig.GetStringDefault("WorldDatabaseInfo", "");
if (dbstring.empty())
@@ -462,18 +448,18 @@ bool Master::_StartDB()
return false;
}
- num_threads = sConfig.GetIntDefault("WorldDatabase.WorkerThreads", 1);
- if (num_threads < 1 || num_threads > 32)
+ async_threads = sConfig.GetIntDefault("WorldDatabase.WorkerThreads", 1);
+ if (async_threads < 1 || async_threads > 32)
{
sLog.outError("World database: invalid number of worker threads specified. "
"Please pick a value between 1 and 32.");
return false;
}
- mask = sConfig.GetIntDefault("WorldDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
+ synch_threads = sConfig.GetIntDefault("WorldDatabase.SynchThreads", 1);
///- Initialise the world database
- if (!WorldDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
+ if (!WorldDatabase.Open(dbstring, async_threads, synch_threads))
{
sLog.outError("Cannot connect to world database %s", dbstring.c_str());
return false;
@@ -486,18 +472,18 @@ bool Master::_StartDB()
return false;
}
- num_threads = sConfig.GetIntDefault("CharacterDatabase.WorkerThreads", 1);
- if (num_threads < 1 || num_threads > 32)
+ async_threads = sConfig.GetIntDefault("CharacterDatabase.WorkerThreads", 1);
+ if (async_threads < 1 || async_threads > 32)
{
sLog.outError("Character database: invalid number of worker threads specified. "
"Please pick a value between 1 and 32.");
return false;
}
- mask = sConfig.GetIntDefault("CharacterDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
+ synch_threads = sConfig.GetIntDefault("CharacterDatabase.SynchThreads", 2);
///- Initialise the Character database
- if (!CharacterDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
+ if (!CharacterDatabase.Open(dbstring, async_threads, synch_threads))
{
sLog.outError("Cannot connect to Character database %s", dbstring.c_str());
return false;
@@ -511,18 +497,18 @@ bool Master::_StartDB()
return false;
}
- num_threads = sConfig.GetIntDefault("LoginDatabase.WorkerThreads", 1);
- if (num_threads < 1 || num_threads > 32)
+ async_threads = sConfig.GetIntDefault("LoginDatabase.WorkerThreads", 1);
+ if (async_threads < 1 || async_threads > 32)
{
sLog.outError("Login database: invalid number of worker threads specified. "
"Please pick a value between 1 and 32.");
return false;
}
- mask = sConfig.GetIntDefault("LoginDatabase.ThreadBundleMask", MYSQL_BUNDLE_ALL);
+ synch_threads = sConfig.GetIntDefault("LoginDatabase.SynchThreads", 1);
///- Initialise the login database
- if (!LoginDatabase.Open(dbstring, num_threads, MySQLThreadBundle(mask)))
+ if (!LoginDatabase.Open(dbstring, async_threads, synch_threads))
{
sLog.outError("Cannot connect to login database %s", dbstring.c_str());
return false;
diff --git a/src/server/worldserver/WorldThread/WorldRunnable.cpp b/src/server/worldserver/WorldThread/WorldRunnable.cpp
index 6dfe0d809a5..8bb7899d6ca 100644
--- a/src/server/worldserver/WorldThread/WorldRunnable.cpp
+++ b/src/server/worldserver/WorldThread/WorldRunnable.cpp
@@ -43,28 +43,6 @@ extern int m_ServiceStatus;
/// Heartbeat for the World
void WorldRunnable::run()
{
- ///- Init MySQL threads or connections
- bool needInit = true;
- if (!(WorldDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- {
- WorldDatabase.Init_MySQL_Connection();
- needInit = false;
- }
- if (!(LoginDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- {
- LoginDatabase.Init_MySQL_Connection();
- needInit = false;
- }
-
- if (!(CharacterDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- {
- CharacterDatabase.Init_MySQL_Connection();
- needInit = false;
- }
-
- if (needInit)
- MySQL::Thread_Init();
-
uint32 realCurrTime = 0;
uint32 realPrevTime = getMSTime();
@@ -116,16 +94,4 @@ void WorldRunnable::run()
sMapMgr.UnloadAll(); // unload all grids (including locked in memory)
- ///- Free MySQL thread resources and deallocate lingering connections
- if (!(WorldDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- WorldDatabase.End_MySQL_Connection();
-
- if (!(LoginDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- LoginDatabase.End_MySQL_Connection();
-
- if (!(CharacterDatabase.GetBundleMask() & MYSQL_BUNDLE_WORLD))
- CharacterDatabase.End_MySQL_Connection();
-
- if (needInit)
- MySQL::Thread_End();
}
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index 51be81430f6..3bbf0cc5f9e 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -39,25 +39,18 @@
# WorldDatabase.WorkerThreads
# CharacterDatabase.WorkerThreads
# The amount of worker threads spawned to handle
-# asynchroneous MySQL statements
+# asynchronous (delayed) MySQL statements.
# Each worker thread is mirrored with its own
# connection to the MySQL server and their own
# thread on the MySQL server.
# Default: 1
#
-# LoginDatabase.ThreadBundleMask
-# WorldDatabase.ThreadBundleMask
-# CharacterDatabase.ThreadBundleMask
-# Defines which runnable threads are bundled into one synchroneous
-# connection. Runnables not specified in the mask will have their
-# seperate connection to the MySQL server.
-# Value is a bitmask consisting of:
-# MYSQL_BUNDLE_NONE = 0, Each task will run their own MySQL connection
-# MYSQL_BUNDLE_CLI = 1, Commandline interface thread
-# MYSQL_BUNDLE_RA = 2, Remote admin thread
-# MYSQL_BUNDLE_RAR = 4, Reactor runnable thread
-# MYSQL_BUNDLE_WORLD = 8, WorldRunnable
-# MYSQL_BUNDLE_ALL = 15, All bundled together
+# LoginDatabase.SynchThreads
+# WorldDatabase.SynchThreads
+# CharacterDatabase.SynchThreads
+# The amount of MySQL connections spawned to handle
+# synchronous (blocking) MySQL statements.
+# Default: 1, 1, 2
#
# MaxPingTime
# Settings for maximum database-ping interval (minutes between pings)
@@ -79,9 +72,9 @@ CharacterDatabaseInfo = "127.0.0.1;3306;trinity;trinity;characters"
LoginDatabase.WorkerThreads = 1
WorldDatabase.WorkerThreads = 1
CharacterDatabase.WorkerThreads = 1
-LoginDatabase.ThreadBundleMask = 15
-WorldDatabase.ThreadBundleMask = 15
-CharacterDatabase.ThreadBundleMask = 15
+LoginDatabase.SynchThreads = 1
+WorldDatabase.SynchThreads = 1
+CharacterDatabase.SynchThreads = 2
MaxPingTime = 30
WorldServerPort = 8085
BindIP = "0.0.0.0"