Index: gazebo-11.15.1/gazebo/transport/Connection.cc =================================================================== --- gazebo-11.15.1.orig/gazebo/transport/Connection.cc +++ gazebo-11.15.1/gazebo/transport/Connection.cc @@ -73,7 +73,7 @@ IOManager *Connection::iomanager = NULL; // is stolen from adress::is_unspecified function in boost v1.52. static bool addressIsUnspecified(const boost::asio::ip::address_v4 &_addr) { - return _addr.to_ulong() == 0; + return _addr.to_uint() == 0; } // Version 1.52 of boost has an address::is_loopback function, but @@ -81,7 +81,7 @@ static bool addressIsUnspecified(const b // is stolen from adress::is_loopback function in boost v1.52. static bool addressIsLoopback(const boost::asio::ip::address_v4 &_addr) { - return (_addr.to_ulong() & 0xFF000000) == 0x7F000000; + return (_addr.to_uint() & 0xFF000000) == 0x7F000000; } ////////////////////////////////////////////////// @@ -151,15 +151,15 @@ bool Connection::Connect(const std::stri host = _host.substr(7, _host.size() - 7); // Resolve the host name into an IP address - boost::asio::ip::tcp::resolver::iterator end; boost::asio::ip::tcp::resolver resolver(iomanager->GetIO()); - boost::asio::ip::tcp::resolver::query query(host, service, + + auto res = resolver.resolve(host, service, boost::asio::ip::resolver_query_base::numeric_service); - boost::asio::ip::tcp::resolver::iterator endpointIter; + auto endpointIter = res.begin(); + auto end = res.end(); try { - endpointIter = resolver.resolve(query); // Find the first valid IPv4 address for (; endpointIter != end && @@ -690,9 +690,9 @@ boost::asio::ip::tcp::endpoint Connectio if (hostname && !std::string(hostname).empty()) { boost::asio::ip::tcp::resolver resolver(iomanager->GetIO()); - boost::asio::ip::tcp::resolver::query query(hostname, ""); - boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(query); - boost::asio::ip::tcp::resolver::iterator end; + auto res = resolver.resolve(hostname, ""); + auto iter = res.begin(); + auto end = res.end(); // Loop through the results, and stop at the first valid address. while (iter != end) @@ -724,7 +724,7 @@ boost::asio::ip::tcp::endpoint Connectio << "] is invalid. We will still try to use it, be warned.\n"; } - address = boost::asio::ip::address_v4::from_string(ip); + address = boost::asio::ip::make_address_v4(ip); } // Try to automatically find a valid address if GAZEBO_IP and @@ -774,7 +774,7 @@ boost::asio::ip::tcp::endpoint Connectio if (!ValidateIP(host)) continue; - address = boost::asio::ip::address_v4::from_string(host); + address = boost::asio::ip::make_address_v4(host); // Also make sure that the IP address is not a loopback interface. if (!addressIsLoopback(address)) @@ -868,7 +868,7 @@ boost::asio::ip::tcp::endpoint Connectio "but will almost certainly not work if you have remote processes." "Report to the disc-zmq development team to seek a fix." << std::endl; } - address = boost::asio::ip::address_v4::from_string(retAddr); + address = boost::asio::ip::make_address_v4(retAddr); #endif } @@ -923,8 +923,9 @@ std::string Connection::GetHostname(boos else { boost::asio::ip::tcp::resolver resolver(iomanager->GetIO()); - boost::asio::ip::tcp::resolver::iterator iter = resolver.resolve(_ep); - boost::asio::ip::tcp::resolver::iterator end; + auto res = resolver.resolve(_ep); + auto iter = res.begin(); + auto end = res.end(); while (iter != end) { @@ -950,7 +951,7 @@ std::string Connection::GetLocalHostname ////////////////////////////////////////////////// void Connection::OnConnect(const boost::system::error_code &_error, - boost::asio::ip::tcp::resolver::iterator /*_endPointIter*/) + boost::asio::ip::tcp::resolver::results_type::iterator /*_endPointIter*/) { // This function is called when a connection is successfully (or // unsuccessfully) established. Index: gazebo-11.15.1/gazebo/transport/Connection.hh =================================================================== --- gazebo-11.15.1.orig/gazebo/transport/Connection.hh +++ gazebo-11.15.1/gazebo/transport/Connection.hh @@ -409,7 +409,7 @@ namespace gazebo /// \param[in] _error Error code thrown during connection /// \param[in] _endPointIter Pointer to resolver iterator private: void OnConnect(const boost::system::error_code &_error, - boost::asio::ip::tcp::resolver::iterator _endPointIter); + boost::asio::ip::tcp::resolver::results_type::iterator _endPointIter); /// \brief Socket pointer private: boost::asio::ip::tcp::socket *socket; Index: gazebo-11.15.1/gazebo/transport/IOManager.cc =================================================================== --- gazebo-11.15.1.orig/gazebo/transport/IOManager.cc +++ gazebo-11.15.1/gazebo/transport/IOManager.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "gazebo/transport/IOManager.hh" @@ -28,10 +29,10 @@ namespace transport class IOManagerPrivate { /// \brief IO service. - public: boost::asio::io_service *io_service = nullptr; + public: boost::asio::io_context *io_service = nullptr; /// \brief Use io_service::work to keep the io_service running in thread. - public: boost::asio::io_service::work *work = nullptr; + //public: boost::asio::executor_work_guard work; /// \brief Reference count of connections using this IOManager. public: std::atomic_int count; @@ -44,12 +45,11 @@ class IOManagerPrivate IOManager::IOManager() : dataPtr(new IOManagerPrivate) { - this->dataPtr->io_service = new boost::asio::io_service; - this->dataPtr->work = new boost::asio::io_service::work( - *this->dataPtr->io_service); + this->dataPtr->io_service = new boost::asio::io_context; + //this->dataPtr->work = boost::asio::make_work_guard(*this->dataPtr->io_service); this->dataPtr->count = 0; this->dataPtr->thread = new boost::thread(boost::bind( - &boost::asio::io_service::run, this->dataPtr->io_service)); + &boost::asio::io_context::run, this->dataPtr->io_service)); } ///////////////////////////////////////////////// @@ -57,9 +57,6 @@ IOManager::~IOManager() { this->Stop(); - delete this->dataPtr->work; - this->dataPtr->work = nullptr; - delete this->dataPtr->io_service; this->dataPtr->io_service = nullptr; @@ -70,7 +67,7 @@ IOManager::~IOManager() ///////////////////////////////////////////////// void IOManager::Stop() { - this->dataPtr->io_service->reset(); + this->dataPtr->io_service->restart(); this->dataPtr->io_service->stop(); if (this->dataPtr->thread) { @@ -81,7 +78,7 @@ void IOManager::Stop() } ///////////////////////////////////////////////// -boost::asio::io_service &IOManager::GetIO() +boost::asio::io_context &IOManager::GetIO() { return *this->dataPtr->io_service; } Index: gazebo-11.15.1/gazebo/transport/IOManager.hh =================================================================== --- gazebo-11.15.1.orig/gazebo/transport/IOManager.hh +++ gazebo-11.15.1/gazebo/transport/IOManager.hh @@ -42,7 +42,7 @@ namespace gazebo /// \brief Get handle to boost::asio IO service /// \return Handle to boost::asio IO service - public: boost::asio::io_service &GetIO(); + public: boost::asio::io_context &GetIO(); /// \brief Increment the event count by 1 public: void IncCount();