1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
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 <atomic>
#include <boost/bind/bind.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/asio/executor_work_guard.hpp>
#include <iostream>
#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<boost::asio::io_context> 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();
|