DBLayer:
- Use ACE_Future and ACE_Future_Set for async SQL queries with callback * Callbacks will now be executed from the thread and object that scheduled the request, instead of the world runnable thread (and thus are no longer dependent on the 50ms forced sleep time). * This design gets rid of a potential DOS loophole in the resultqueue system - unique requests will be cancelled when re-requested. - Drop now redundant SQLQueryTask, SQLResultQueue, SQLResultQueueTask operations. - Drop now redundant CharacterHandler class - Change static callback functions in WorldSession to normal functions. Thanks to Derex and Zor for advice along the way. --HG-- branch : trunk
This commit is contained in:
1 parent
2ffe785765
commit
d845a903b1
15 files changed
+303
-862
No files matched your search
@@ -290,6 +290,8 @@ bool WorldSession::Update(uint32 diff)
|
||||
delete packet;
|
||||
}
|
||||
|
||||
ProcessQueryCallbacks();
|
||||
|
||||
time_t currTime = time(NULL);
|
||||
///- If necessary, log the player out
|
||||
if (ShouldLogOut(currTime) && !m_playerLoading)
|
||||
@@ -955,3 +957,63 @@ void WorldSession::SetPlayer(Player *plr)
|
||||
if (_player)
|
||||
m_GUIDLow = _player->GetGUIDLow();
|
||||
}
|
||||
|
||||
void WorldSession::ProcessQueryCallbacks()
|
||||
{
|
||||
QueryResult_AutoPtr result;
|
||||
|
||||
//! HandleNameQueryOpcode
|
||||
while (!m_nameQueryCallbacks.is_empty())
|
||||
{
|
||||
QueryResultFuture lResult;
|
||||
ACE_Time_Value timeout = ACE_Time_Value::zero;
|
||||
if (m_nameQueryCallbacks.next_readable(lResult, &timeout) != 1)
|
||||
break;
|
||||
|
||||
lResult.get(result);
|
||||
SendNameQueryOpcodeFromDBCallBack(result);
|
||||
}
|
||||
|
||||
//! HandleCharEnumOpcode
|
||||
if (m_charEnumCallback.ready())
|
||||
{
|
||||
m_charEnumCallback.get(result);
|
||||
HandleCharEnum(result);
|
||||
m_charEnumCallback.cancel();
|
||||
}
|
||||
|
||||
//! HandlePlayerLoginOpcode
|
||||
if (m_charLoginCallback.ready())
|
||||
{
|
||||
SQLQueryHolder* param;
|
||||
m_charLoginCallback.get(param);
|
||||
HandlePlayerLogin((LoginQueryHolder*)param);
|
||||
m_charLoginCallback.cancel();
|
||||
}
|
||||
|
||||
//! HandleAddFriendOpcode
|
||||
if (m_addFriendCallback.IsReady())
|
||||
{
|
||||
std::string& param = m_addFriendCallback.GetParam();
|
||||
m_addFriendCallback.GetResult(result);
|
||||
HandleAddFriendOpcodeCallBack(result, param);
|
||||
m_addFriendCallback.FreeResult();
|
||||
}
|
||||
|
||||
//- HandleCharRenameOpcode
|
||||
if (m_charRenameCallback.IsReady())
|
||||
{
|
||||
std::string& param = m_charRenameCallback.GetParam();
|
||||
m_charRenameCallback.GetResult(result);
|
||||
HandleChangePlayerNameOpcodeCallBack(result, param);
|
||||
m_charRenameCallback.FreeResult();
|
||||
}
|
||||
|
||||
//- HandleCharAddIgnoreOpcode
|
||||
if (m_addIgnoreCallback.ready())
|
||||
{
|
||||
m_addIgnoreCallback.get(result);
|
||||
HandleAddIgnoreOpcodeCallBack(result);
|
||||
m_addIgnoreCallback.cancel();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user