mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Dep: Boost 1.70 compatibility
This commit is contained in:
@@ -46,29 +46,25 @@ namespace boost
|
||||
|
||||
typedef basic_endpoint<tcp> tcp_endpoint;
|
||||
}
|
||||
#if BOOST_VERSION >= 107000
|
||||
class executor;
|
||||
|
||||
#if BOOST_VERSION >= 106600
|
||||
template <typename Time, typename TimeTraits>
|
||||
class basic_deadline_timer;
|
||||
|
||||
typedef basic_deadline_timer<posix_time::ptime, time_traits<posix_time::ptime>> deadline_timer;
|
||||
namespace ip
|
||||
{
|
||||
template <typename InternetProtocol, typename Executor>
|
||||
class basic_resolver;
|
||||
|
||||
typedef basic_resolver<tcp, executor> tcp_resolver;
|
||||
}
|
||||
#elif BOOST_VERSION >= 106600
|
||||
namespace ip
|
||||
{
|
||||
template <typename InternetProtocol>
|
||||
class basic_resolver;
|
||||
|
||||
typedef basic_resolver<tcp> tcp_resolver;
|
||||
}
|
||||
}
|
||||
#else
|
||||
template <typename TimeType, typename TimeTraits>
|
||||
class deadline_timer_service;
|
||||
|
||||
template <typename Time, typename TimeTraits, typename TimerService>
|
||||
class basic_deadline_timer;
|
||||
|
||||
typedef basic_deadline_timer<posix_time::ptime, time_traits<posix_time::ptime>, deadline_timer_service<posix_time::ptime, time_traits<posix_time::ptime>>> deadline_timer;
|
||||
|
||||
namespace ip
|
||||
{
|
||||
template <typename InternetProtocol>
|
||||
|
||||
45
src/common/Asio/DeadlineTimer.h
Normal file
45
src/common/Asio/DeadlineTimer.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DeadlineTimer_h__
|
||||
#define DeadlineTimer_h__
|
||||
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
|
||||
#if BOOST_VERSION >= 107000
|
||||
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::io_context::executor_type
|
||||
#elif BOOST_VERSION >= 106600
|
||||
#define BasicDeadlineTimerThirdTemplateArg
|
||||
#else
|
||||
#define BasicDeadlineTimerThirdTemplateArg , boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>>
|
||||
#endif
|
||||
|
||||
#define DeadlineTimerBase boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> BasicDeadlineTimerThirdTemplateArg>
|
||||
|
||||
namespace Trinity
|
||||
{
|
||||
namespace Asio
|
||||
{
|
||||
class DeadlineTimer : public DeadlineTimerBase
|
||||
{
|
||||
public:
|
||||
using DeadlineTimerBase::basic_deadline_timer;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DeadlineTimer_h__
|
||||
@@ -35,9 +35,24 @@ namespace Trinity
|
||||
{
|
||||
namespace Asio
|
||||
{
|
||||
class IoContext : public IoContextBaseNamespace::IoContextBase
|
||||
class IoContext
|
||||
{
|
||||
using IoContextBaseNamespace::IoContextBase::IoContextBase;
|
||||
public:
|
||||
IoContext() : _impl() { }
|
||||
explicit IoContext(int concurrency_hint) : _impl(concurrency_hint) { }
|
||||
|
||||
operator IoContextBaseNamespace::IoContextBase&() { return _impl; }
|
||||
operator IoContextBaseNamespace::IoContextBase const&() const { return _impl; }
|
||||
|
||||
std::size_t run() { return _impl.run(); }
|
||||
void stop() { _impl.stop(); }
|
||||
|
||||
#if BOOST_VERSION >= 106600
|
||||
boost::asio::io_context::executor_type get_executor() noexcept { return _impl.get_executor(); }
|
||||
#endif
|
||||
|
||||
private:
|
||||
IoContextBaseNamespace::IoContextBase _impl;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -18,19 +18,19 @@
|
||||
#include "Metric.h"
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "Log.h"
|
||||
#include "Strand.h"
|
||||
#include "Util.h"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
|
||||
void Metric::Initialize(std::string const& realmName, Trinity::Asio::IoContext& ioContext, std::function<void()> overallStatusLogger)
|
||||
{
|
||||
_dataStream = Trinity::make_unique<boost::asio::ip::tcp::iostream>();
|
||||
_realmName = FormatInfluxDBTagValue(realmName);
|
||||
_batchTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioContext);
|
||||
_overallStatusTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioContext);
|
||||
_batchTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
|
||||
_overallStatusTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
|
||||
_overallStatusLogger = overallStatusLogger;
|
||||
LoadFromConfigs();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#define METRIC_H__
|
||||
|
||||
#include "Define.h"
|
||||
#include "AsioHacksFwd.h"
|
||||
#include "MPSCQueue.h"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -32,6 +31,7 @@ namespace Trinity
|
||||
namespace Asio
|
||||
{
|
||||
class IoContext;
|
||||
class DeadlineTimer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ private:
|
||||
std::iostream& GetDataStream() { return *_dataStream; }
|
||||
std::unique_ptr<std::iostream> _dataStream;
|
||||
MPSCQueue<MetricData> _queuedData;
|
||||
std::unique_ptr<boost::asio::deadline_timer> _batchTimer;
|
||||
std::unique_ptr<boost::asio::deadline_timer> _overallStatusTimer;
|
||||
std::unique_ptr<Trinity::Asio::DeadlineTimer> _batchTimer;
|
||||
std::unique_ptr<Trinity::Asio::DeadlineTimer> _overallStatusTimer;
|
||||
int32 _updateInterval = 0;
|
||||
int32 _overallStatusTimerInterval = 0;
|
||||
bool _enabled = false;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "GitRevision.h"
|
||||
#include "IPLocation.h"
|
||||
#include "LoginRESTService.h"
|
||||
@@ -65,14 +66,14 @@ char serviceDescription[] = "TrinityCore Battle.net emulator authentication serv
|
||||
*/
|
||||
int m_ServiceStatus = -1;
|
||||
|
||||
void ServiceStatusWatcher(std::weak_ptr<boost::asio::deadline_timer> serviceStatusWatchTimerRef, std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::system::error_code const& error);
|
||||
void ServiceStatusWatcher(std::weak_ptr<Trinity::Asio::DeadlineTimer> serviceStatusWatchTimerRef, std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::system::error_code const& error);
|
||||
#endif
|
||||
|
||||
bool StartDB();
|
||||
void StopDB();
|
||||
void SignalHandler(std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::system::error_code const& error, int signalNumber);
|
||||
void KeepDatabaseAliveHandler(std::weak_ptr<boost::asio::deadline_timer> dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error);
|
||||
void BanExpiryHandler(std::weak_ptr<boost::asio::deadline_timer> banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error);
|
||||
void KeepDatabaseAliveHandler(std::weak_ptr<Trinity::Asio::DeadlineTimer> dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error);
|
||||
void BanExpiryHandler(std::weak_ptr<Trinity::Asio::DeadlineTimer> banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error);
|
||||
variables_map GetConsoleArguments(int argc, char** argv, fs::path& configFile, std::string& configService);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
@@ -202,23 +203,23 @@ int main(int argc, char** argv)
|
||||
|
||||
// Enabled a timed callback for handling the database keep alive ping
|
||||
int32 dbPingInterval = sConfigMgr->GetIntDefault("MaxPingTime", 30);
|
||||
std::shared_ptr<boost::asio::deadline_timer> dbPingTimer = std::make_shared<boost::asio::deadline_timer>(*ioContext);
|
||||
std::shared_ptr<Trinity::Asio::DeadlineTimer> dbPingTimer = std::make_shared<Trinity::Asio::DeadlineTimer>(*ioContext);
|
||||
dbPingTimer->expires_from_now(boost::posix_time::minutes(dbPingInterval));
|
||||
dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr<boost::asio::deadline_timer>(dbPingTimer), dbPingInterval, std::placeholders::_1));
|
||||
dbPingTimer->async_wait(std::bind(&KeepDatabaseAliveHandler, std::weak_ptr<Trinity::Asio::DeadlineTimer>(dbPingTimer), dbPingInterval, std::placeholders::_1));
|
||||
|
||||
int32 banExpiryCheckInterval = sConfigMgr->GetIntDefault("BanExpiryCheckInterval", 60);
|
||||
std::shared_ptr<boost::asio::deadline_timer> banExpiryCheckTimer = std::make_shared<boost::asio::deadline_timer>(*ioContext);
|
||||
std::shared_ptr<Trinity::Asio::DeadlineTimer> banExpiryCheckTimer = std::make_shared<Trinity::Asio::DeadlineTimer>(*ioContext);
|
||||
banExpiryCheckTimer->expires_from_now(boost::posix_time::seconds(banExpiryCheckInterval));
|
||||
banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr<boost::asio::deadline_timer>(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1));
|
||||
banExpiryCheckTimer->async_wait(std::bind(&BanExpiryHandler, std::weak_ptr<Trinity::Asio::DeadlineTimer>(banExpiryCheckTimer), banExpiryCheckInterval, std::placeholders::_1));
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
std::shared_ptr<boost::asio::deadline_timer> serviceStatusWatchTimer;
|
||||
std::shared_ptr<Trinity::Asio::DeadlineTimer> serviceStatusWatchTimer;
|
||||
if (m_ServiceStatus != -1)
|
||||
{
|
||||
serviceStatusWatchTimer = std::make_shared<boost::asio::deadline_timer>(*ioContext);
|
||||
serviceStatusWatchTimer = std::make_shared<Trinity::Asio::DeadlineTimer>(*ioContext);
|
||||
serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1));
|
||||
serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher,
|
||||
std::weak_ptr<boost::asio::deadline_timer>(serviceStatusWatchTimer),
|
||||
std::weak_ptr<Trinity::Asio::DeadlineTimer>(serviceStatusWatchTimer),
|
||||
std::weak_ptr<Trinity::Asio::IoContext>(ioContext),
|
||||
std::placeholders::_1));
|
||||
}
|
||||
@@ -269,11 +270,11 @@ void SignalHandler(std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::
|
||||
ioContext->stop();
|
||||
}
|
||||
|
||||
void KeepDatabaseAliveHandler(std::weak_ptr<boost::asio::deadline_timer> dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error)
|
||||
void KeepDatabaseAliveHandler(std::weak_ptr<Trinity::Asio::DeadlineTimer> dbPingTimerRef, int32 dbPingInterval, boost::system::error_code const& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
if (std::shared_ptr<boost::asio::deadline_timer> dbPingTimer = dbPingTimerRef.lock())
|
||||
if (std::shared_ptr<Trinity::Asio::DeadlineTimer> dbPingTimer = dbPingTimerRef.lock())
|
||||
{
|
||||
TC_LOG_INFO("server.bnetserver", "Ping MySQL to keep connection alive");
|
||||
LoginDatabase.KeepAlive();
|
||||
@@ -284,11 +285,11 @@ void KeepDatabaseAliveHandler(std::weak_ptr<boost::asio::deadline_timer> dbPingT
|
||||
}
|
||||
}
|
||||
|
||||
void BanExpiryHandler(std::weak_ptr<boost::asio::deadline_timer> banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error)
|
||||
void BanExpiryHandler(std::weak_ptr<Trinity::Asio::DeadlineTimer> banExpiryCheckTimerRef, int32 banExpiryCheckInterval, boost::system::error_code const& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
if (std::shared_ptr<boost::asio::deadline_timer> banExpiryCheckTimer = banExpiryCheckTimerRef.lock())
|
||||
if (std::shared_ptr<Trinity::Asio::DeadlineTimer> banExpiryCheckTimer = banExpiryCheckTimerRef.lock())
|
||||
{
|
||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_DEL_EXPIRED_IP_BANS));
|
||||
LoginDatabase.Execute(LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPIRED_ACCOUNT_BANS));
|
||||
@@ -301,7 +302,7 @@ void BanExpiryHandler(std::weak_ptr<boost::asio::deadline_timer> banExpiryCheckT
|
||||
}
|
||||
|
||||
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
|
||||
void ServiceStatusWatcher(std::weak_ptr<boost::asio::deadline_timer> serviceStatusWatchTimerRef, std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::system::error_code const& error)
|
||||
void ServiceStatusWatcher(std::weak_ptr<Trinity::Asio::DeadlineTimer> serviceStatusWatchTimerRef, std::weak_ptr<Trinity::Asio::IoContext> ioContextRef, boost::system::error_code const& error)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
@@ -311,7 +312,7 @@ void ServiceStatusWatcher(std::weak_ptr<boost::asio::deadline_timer> serviceStat
|
||||
{
|
||||
ioContext->stop();
|
||||
}
|
||||
else if (std::shared_ptr<boost::asio::deadline_timer> serviceStatusWatchTimer = serviceStatusWatchTimerRef.lock())
|
||||
else if (std::shared_ptr<Trinity::Asio::DeadlineTimer> serviceStatusWatchTimer = serviceStatusWatchTimerRef.lock())
|
||||
{
|
||||
serviceStatusWatchTimer->expires_from_now(boost::posix_time::seconds(1));
|
||||
serviceStatusWatchTimer->async_wait(std::bind(&ServiceStatusWatcher, serviceStatusWatchTimerRef, ioContext, std::placeholders::_1));
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#define NetworkThread_h__
|
||||
|
||||
#include "Define.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "Errors.h"
|
||||
#include "IoContext.h"
|
||||
#include "Log.h"
|
||||
#include "Timer.h"
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
@@ -173,7 +173,7 @@ private:
|
||||
|
||||
Trinity::Asio::IoContext _ioContext;
|
||||
tcp::socket _acceptSocket;
|
||||
boost::asio::deadline_timer _updateTimer;
|
||||
Trinity::Asio::DeadlineTimer _updateTimer;
|
||||
};
|
||||
|
||||
#endif // NetworkThread_h__
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "BattlenetRpcErrorCodes.h"
|
||||
#include "BigNumber.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "Errors.h"
|
||||
#include "IoContext.h"
|
||||
#include "Log.h"
|
||||
@@ -28,7 +29,6 @@
|
||||
#include "Util.h"
|
||||
#include "game_utilities_service.pb.h"
|
||||
#include "RealmList.pb.h"
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
@@ -53,7 +53,7 @@ RealmList* RealmList::Instance()
|
||||
void RealmList::Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInterval)
|
||||
{
|
||||
_updateInterval = updateInterval;
|
||||
_updateTimer = Trinity::make_unique<boost::asio::deadline_timer>(ioContext);
|
||||
_updateTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
|
||||
_resolver = Trinity::make_unique<boost::asio::ip::tcp::resolver>(ioContext);
|
||||
|
||||
// Get the content of the realmlist table in the database
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace Trinity
|
||||
namespace Asio
|
||||
{
|
||||
class IoContext;
|
||||
class DeadlineTimer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ private:
|
||||
RealmMap _realms;
|
||||
std::unordered_set<std::string> _subRegions;
|
||||
uint32 _updateInterval;
|
||||
std::unique_ptr<boost::asio::deadline_timer> _updateTimer;
|
||||
std::unique_ptr<Trinity::Asio::DeadlineTimer> _updateTimer;
|
||||
std::unique_ptr<boost::asio::ip::tcp_resolver> _resolver;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Configuration/Config.h"
|
||||
#include "DatabaseEnv.h"
|
||||
#include "DatabaseLoader.h"
|
||||
#include "DeadlineTimer.h"
|
||||
#include "GitRevision.h"
|
||||
#include "InstanceSaveMgr.h"
|
||||
#include "IoContext.h"
|
||||
@@ -51,7 +52,6 @@
|
||||
#include "WorldSocketMgr.h"
|
||||
#include <openssl/opensslv.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/filesystem/operations.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
static void Handler(std::weak_ptr<FreezeDetector> freezeDetectorRef, boost::system::error_code const& error);
|
||||
|
||||
private:
|
||||
boost::asio::deadline_timer _timer;
|
||||
Trinity::Asio::DeadlineTimer _timer;
|
||||
uint32 _worldLoopCounter;
|
||||
uint32 _lastChangeMsTime;
|
||||
uint32 _maxCoreStuckTimeInMs;
|
||||
|
||||
Reference in New Issue
Block a user