Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bef8be

Browse files
enricodetomadeanberris
authored andcommitted
Fix for boost 1.70 (get_io_service() was deprecated and was removed) (#878)
Introduces a compatibility header which consolidates the definition of all macros related to deprecated/removed patterns.
1 parent0a4d2a6 commit2bef8be

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

‎boost/network/compat.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#ifndef BOOST_NETWORK_COMPAT_HPP__
2+
#defineBOOST_NETWORK_COMPAT_HPP__
3+
4+
// Copyright 2019 (C) Enrico Detoma
5+
// Distributed under the Boost Software License, Version 1.0.
6+
// (See accompanying file LICENSE_1_0.txt or copy at
7+
// http://www.boost.org/LICENSE_1_0.txt)
8+
9+
// These macros are used to solve a compatibility problem with Boost >= 1.70
10+
// where the deprecated method get_io_service() was removed.
11+
#if BOOST_VERSION >= 107000
12+
#defineCPP_NETLIB_ASIO_GET_IO_SERVICE(s) ((boost::asio::io_context&)(s).get_executor().context())
13+
#defineCPP_NETLIB_ASIO_IO_SERVICE_CONTEXTboost::asio::io_context
14+
#else
15+
#defineCPP_NETLIB_ASIO_GET_IO_SERVICE(s) ((s).get_io_service())
16+
#defineCPP_NETLIB_ASIO_IO_SERVICE_CONTEXTboost::asio::io_service
17+
#endif
18+
19+
#endif// BOOST_NETWORK_COMPAT_HPP__

‎boost/network/protocol/http/client/connection/async_base.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include<boost/network/protocol/http/client/connection/async_normal.hpp>
1717
#include<boost/network/protocol/http/traits/resolver_policy.hpp>
1818
#include<boost/network/traits/string.hpp>
19+
#include<boost/network/compat.hpp>
1920

2021
namespaceboost {
2122
namespacenetwork {
@@ -59,7 +60,7 @@ struct async_connection_base {
5960
async_connection;
6061
typedeftypename delegate_factory<Tag>::type delegate_factory_type;
6162
auto delegate =delegate_factory_type::new_connection_delegate(
62-
resolver.get_io_service(), https, always_verify_peer,
63+
CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), https, always_verify_peer,
6364
certificate_filename, verify_path, certificate_file, private_key_file,
6465
ciphers, sni_hostname, ssl_options);
6566
auto temp = std::make_shared<async_connection>(

‎boost/network/protocol/http/client/connection/async_normal.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include<boost/range/algorithm/transform.hpp>
3333
#include<boost/range/iterator_range.hpp>
3434
#include<boost/throw_exception.hpp>
35+
#include<boost/network/compat.hpp>
3536

3637
namespaceboost {
3738
namespacenetwork {
@@ -154,12 +155,12 @@ struct http_async_connection
154155
connection_delegate_ptr delegate)
155156
: timeout_(timeout),
156157
remove_chunk_markers_(remove_chunk_markers),
157-
timer_(resolver.get_io_service()),
158+
timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)),
158159
is_timedout_(false),
159160
follow_redirect_(follow_redirect),
160161
resolver_(resolver),
161162
resolve_(std::move(resolve)),
162-
request_strand_(resolver.get_io_service()),
163+
request_strand_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)),
163164
delegate_(std::move(delegate)) {}
164165

165166
// This is the main entry point for the connection/request pipeline.

‎boost/network/protocol/http/client/connection/connection_delegate_factory.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ struct connection_delegate_factory {
3434
// This is the factory method that actually returns the delegate instance.
3535
// TODO(dberris): Support passing in proxy settings when crafting connections.
3636
static connection_delegate_ptrnew_connection_delegate(
37-
boost::asio::io_service& service,bool https,bool always_verify_peer,
37+
CPP_NETLIB_ASIO_IO_SERVICE_CONTEXT& service,
38+
bool https,bool always_verify_peer,
3839
optional<string_type> certificate_filename,
3940
optional<string_type> verify_path, optional<string_type> certificate_file,
4041
optional<string_type> private_key_file, optional<string_type> ciphers,

‎boost/network/protocol/http/client/connection/sync_normal.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include<boost/network/protocol/http/response.hpp>
1717
#include<boost/network/protocol/http/traits/resolver_policy.hpp>
1818
#include<boost/network/traits/string.hpp>
19+
#include<boost/network/compat.hpp>
1920

2021
namespaceboost {
2122
namespacenetwork {
@@ -49,10 +50,10 @@ struct http_sync_connection
4950
int timeout)
5051
: connection_base(),
5152
timeout_(timeout),
52-
timer_(resolver.get_io_service()),
53+
timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)),
5354
resolver_(resolver),
5455
resolve_(std::move(resolve)),
55-
socket_(resolver.get_io_service()) {}
56+
socket_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)) {}
5657

5758
voidinit_socket(string_typeconst& hostname, string_typeconst& port) {
5859
connection_base::init_socket(socket_, resolver_, hostname, port, resolve_);

‎boost/network/protocol/http/client/connection/sync_ssl.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include<boost/algorithm/string/predicate.hpp>
1717
#include<boost/network/protocol/http/request.hpp>
1818
#include<boost/network/protocol/http/traits/resolver_policy.hpp>
19+
#include<boost/network/compat.hpp>
1920

2021
namespaceboost {
2122
namespacenetwork {
@@ -60,11 +61,11 @@ struct https_sync_connection
6061
long ssl_options =0)
6162
: connection_base(),
6263
timeout_(timeout),
63-
timer_(resolver.get_io_service()),
64+
timer_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver)),
6465
resolver_(resolver),
6566
resolve_(std::move(resolve)),
66-
context_(resolver.get_io_service(), boost::asio::ssl::context::sslv23_client),
67-
socket_(resolver.get_io_service(), context_) {
67+
context_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), boost::asio::ssl::context::sslv23_client),
68+
socket_(CPP_NETLIB_ASIO_GET_IO_SERVICE(resolver), context_) {
6869
if (ciphers) {
6970
::SSL_CTX_set_cipher_list(context_.native_handle(), ciphers->c_str());
7071
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp