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
|
diff --git a/src/common/Graylog.cc b/src/common/Graylog.cc
index cbd63fab25f..1b45c7c233d 100644
--- a/src/common/Graylog.cc
+++ b/src/common/Graylog.cc
@@ -34,8 +34,10 @@ void Graylog::set_destination(const std::string& host, int port)
{
try {
boost::asio::ip::udp::resolver resolver(m_io_service);
- boost::asio::ip::udp::resolver::query query(host, std::to_string(port));
- m_endpoint = *resolver.resolve(query);
+ auto ret = resolver.resolve(host, std::to_string(port));
+ // ret is guaranteed to be a non-empty list in the case of success
+ // so this deref-through-iterator is valid (as of boost 1.87)
+ m_endpoint = (*(ret.begin())).endpoint();
m_log_dst_valid = true;
} catch (boost::system::system_error const& e) {
cerr << "Error resolving graylog destination: " << e.what() << std::endl;
diff --git a/src/exporter/DaemonMetricCollector.cc b/src/exporter/DaemonMetricCollector.cc
index cdcc859e8dc..0b71fb704e5 100644
--- a/src/exporter/DaemonMetricCollector.cc
+++ b/src/exporter/DaemonMetricCollector.cc
@@ -38,7 +38,7 @@ void DaemonMetricCollector::request_loop(boost::asio::steady_timer &timer) {
dump_asok_metrics(false, -1, true, dump_response, schema_response, true);
auto stats_period = g_conf().get_val<int64_t>("exporter_stats_period");
// time to wait before sending requests again
- timer.expires_from_now(std::chrono::seconds(stats_period));
+ timer.expires_after(std::chrono::seconds(stats_period));
request_loop(timer);
});
}
diff --git a/src/rgw/driver/rados/rgw_notify.cc b/src/rgw/driver/rados/rgw_notify.cc
index b3437c6685e..48aaa2673a6 100644
--- a/src/rgw/driver/rados/rgw_notify.cc
+++ b/src/rgw/driver/rados/rgw_notify.cc
@@ -169,7 +169,7 @@ private:
if (pending_tokens == 0) {
return;
}
- timer.expires_from_now(infinite_duration);
+ timer.expires_after(infinite_duration);
boost::system::error_code ec;
timer.async_wait(yield[ec]);
ceph_assert(ec == boost::system::errc::operation_canceled);
@@ -288,7 +288,7 @@ private:
<< ". error: " << ret << dendl;
}
Timer timer(io_context);
- timer.expires_from_now(std::chrono::seconds(reservations_cleanup_period_s));
+ timer.expires_after(std::chrono::seconds(reservations_cleanup_period_s));
boost::system::error_code ec;
timer.async_wait(yield[ec]);
}
@@ -371,7 +371,7 @@ private:
// if queue was empty the last time, sleep for idle timeout
if (is_idle) {
Timer timer(io_context);
- timer.expires_from_now(std::chrono::microseconds(queue_idle_sleep_us));
+ timer.expires_after(std::chrono::microseconds(queue_idle_sleep_us));
boost::system::error_code ec;
timer.async_wait(yield[ec]);
}
@@ -640,7 +640,7 @@ private:
const auto duration = (has_error ?
std::chrono::milliseconds(queues_update_retry_ms) : std::chrono::milliseconds(queues_update_period_ms)) +
std::chrono::milliseconds(duration_jitter(rnd_gen));
- timer.expires_from_now(duration);
+ timer.expires_after(duration);
const auto tp = ceph::coarse_real_time::clock::to_time_t(ceph::coarse_real_time::clock::now() + duration);
ldpp_dout(this, 20) << "INFO: next queues processing will happen at: " << std::ctime(&tp) << dendl;
boost::system::error_code ec;
@@ -726,7 +726,7 @@ private:
Timer timer(io_context);
while (processed_queue_count > 0) {
ldpp_dout(this, 5) << "INFO: manager stopped. " << processed_queue_count << " queues are still being processed" << dendl;
- timer.expires_from_now(std::chrono::milliseconds(queues_update_retry_ms));
+ timer.expires_after(std::chrono::milliseconds(queues_update_retry_ms));
boost::system::error_code ec;
timer.async_wait(yield[ec]);
}
diff --git a/src/test/neorados/completions.cc b/src/test/neorados/completions.cc
index b6286130bbe..a4684e4dc51 100644
--- a/src/test/neorados/completions.cc
+++ b/src/test/neorados/completions.cc
@@ -1,4 +1,5 @@
#include <boost/asio/io_context.hpp>
+#include <boost/asio/post.hpp>
constexpr int max_completions = 10'000'000;
int completed = 0;
@@ -7,11 +8,11 @@ boost::asio::io_context c;
void nested_cb() {
if (++completed < max_completions)
- c.post(&nested_cb);
+ boost::asio::post(c, &nested_cb);
}
int main(void) {
- c.post(&nested_cb);
+ boost::asio::post(c, &nested_cb);
c.run();
assert(completed == max_completions);
return 0;
diff --git a/src/tools/immutable_object_cache/CacheClient.cc b/src/tools/immutable_object_cache/CacheClient.cc
index 44686529547..d0358163044 100644
--- a/src/tools/immutable_object_cache/CacheClient.cc
+++ b/src/tools/immutable_object_cache/CacheClient.cc
@@ -20,7 +20,7 @@ namespace ceph {
namespace immutable_obj_cache {
CacheClient::CacheClient(const std::string& file, CephContext* ceph_ctx)
- : m_cct(ceph_ctx), m_io_service_work(m_io_service),
+ : m_cct(ceph_ctx), m_io_service_work(m_io_service.get_executor()),
m_dm_socket(m_io_service), m_ep(stream_protocol::endpoint(file)),
m_io_thread(nullptr), m_session_work(false), m_writing(false),
m_reading(false), m_sequence_id(0) {
@@ -30,7 +30,7 @@ namespace immutable_obj_cache {
if (m_worker_thread_num != 0) {
m_worker = new boost::asio::io_context();
- m_worker_io_service_work = new boost::asio::io_context::work(*m_worker);
+ m_worker_io_service_work = new boost::asio::executor_work_guard<decltype(m_io_service.get_executor())>(m_worker->get_executor());
for (uint64_t i = 0; i < m_worker_thread_num; i++) {
std::thread* thd = new std::thread([this](){m_worker->run();});
m_worker_threads.push_back(thd);
@@ -299,7 +299,7 @@ namespace immutable_obj_cache {
});
if (m_worker_thread_num != 0) {
- m_worker->post([process_reply]() {
+ boost::asio::post(*m_worker, [process_reply]() {
process_reply->complete(true);
});
} else {
diff --git a/src/tools/immutable_object_cache/CacheClient.h b/src/tools/immutable_object_cache/CacheClient.h
index 7dc4aa76c13..6220d4681e0 100644
--- a/src/tools/immutable_object_cache/CacheClient.h
+++ b/src/tools/immutable_object_cache/CacheClient.h
@@ -6,6 +6,7 @@
#include <atomic>
#include <boost/asio/io_context.hpp>
+#include <boost/asio/executor_work_guard.hpp>
#include <boost/asio/local/stream_protocol.hpp>
#include <boost/algorithm/string.hpp>
@@ -58,7 +59,7 @@ class CacheClient {
private:
CephContext* m_cct;
boost::asio::io_context m_io_service;
- boost::asio::io_context::work m_io_service_work;
+ boost::asio::executor_work_guard<decltype(m_io_service.get_executor())> m_io_service_work;
stream_protocol::socket m_dm_socket;
stream_protocol::endpoint m_ep;
std::shared_ptr<std::thread> m_io_thread;
@@ -67,7 +68,7 @@ class CacheClient {
uint64_t m_worker_thread_num;
boost::asio::io_context* m_worker;
std::vector<std::thread*> m_worker_threads;
- boost::asio::io_context::work* m_worker_io_service_work;
+ boost::asio::executor_work_guard<decltype(m_worker->get_executor())>* m_worker_io_service_work;
std::atomic<bool> m_writing;
std::atomic<bool> m_reading;
diff --git a/src/tools/immutable_object_cache/CacheServer.cc b/src/tools/immutable_object_cache/CacheServer.cc
index 14deddce561..bf3a6bda73c 100644
--- a/src/tools/immutable_object_cache/CacheServer.cc
+++ b/src/tools/immutable_object_cache/CacheServer.cc
@@ -35,10 +35,11 @@ int CacheServer::run() {
return ret;
}
- boost::system::error_code ec;
- ret = m_io_service.run(ec);
- if (ec) {
- ldout(cct, 1) << "m_io_service run fails: " << ec.message() << dendl;
+ try {
+ ret = m_io_service.run();
+ }
+ catch (const std::exception& e) {
+ ldout(cct, 1) << "m_io_service run fails: " << e.what() << dendl;
return -1;
}
return 0;
@@ -66,7 +67,7 @@ int CacheServer::start_accept() {
return -ec.value();
}
- m_acceptor.listen(boost::asio::socket_base::max_connections, ec);
+ m_acceptor.listen(boost::asio::socket_base::max_listen_connections, ec);
if (ec) {
lderr(cct) << "failed to listen on domain socket: " << ec.message()
<< dendl;
|