mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 08:55:32 +01:00
Core/Auth: Moved expiring bans to background task - no longer blocking queries during login by default running every minute (configurable)
This commit is contained in:
@@ -73,6 +73,8 @@ variables_map GetConsoleArguments(int argc, char** argv, std::string& configFile
|
||||
boost::asio::io_service* _ioService;
|
||||
boost::asio::deadline_timer* _dbPingTimer;
|
||||
uint32 _dbPingInterval;
|
||||
boost::asio::deadline_timer* _banExpiryCheckTimer;
|
||||
uint32 _banExpiryCheckInterval;
|
||||
LoginDatabaseWorkerPool LoginDatabase;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -169,6 +171,11 @@ int main(int argc, char** argv)
|
||||
_dbPingTimer->expires_from_now(boost::posix_time::minutes(_dbPingInterval));
|
||||
_dbPingTimer->async_wait(KeepDatabaseAliveHandler);
|
||||
|
||||
_banExpiryCheckInterval = sConfigMgr->GetIntDefault("BanExpiryCheckInterval", 60);
|
||||
_banExpiryCheckTimer = new boost::asio::deadline_timer(*_ioService);
|
||||
_banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(_banExpiryCheckInterval));
|
||||
_banExpiryCheckTimer->async_wait(BanExpiryHandler);
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
if (m_ServiceStatus != -1)
|
||||
{
|
||||
@@ -192,6 +199,7 @@ int main(int argc, char** argv)
|
||||
|
||||
signals.cancel();
|
||||
|
||||
delete _banExpiryCheckTimer;
|
||||
delete _dbPingTimer;
|
||||
delete _ioService;
|
||||
return 0;
|
||||
@@ -242,6 +250,18 @@ void KeepDatabaseAliveHandler(const boost::system::error_code& error)
|
||||
}
|
||||
}
|
||||
|
||||
void BanExpiryHandler(boost::system::error_code const& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
|
||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS));
|
||||
|
||||
_banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(_banExpiryCheckInterval));
|
||||
_banExpiryCheckTimer->async_wait(BanExpiryHandler);
|
||||
}
|
||||
}
|
||||
|
||||
#if PLATFORM == PLATFORM_WINDOWS
|
||||
void ServiceStatusWatcher(boost::system::error_code const& error)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user