Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/asio_client_session_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,15 @@ void session_impl::start_resolve(const std::string &host,

auto self = shared_from_this();

resolver_.async_resolve({host, service},
resolver_.async_resolve(host, service,
[self](const boost::system::error_code &ec,
tcp::resolver::iterator endpoint_it) {
tcp::resolver::results_type endpoints) {
if (ec) {
self->not_connected(ec);
return;
}

self->start_connect(endpoint_it);
self->start_connect(endpoints.begin());
});

deadline_.async_wait(std::bind(&session_impl::handle_deadline, self));
Expand Down Expand Up @@ -124,7 +124,7 @@ void session_impl::handle_ping(const boost::system::error_code &ec) {
start_ping();
}

void session_impl::connected(tcp::resolver::iterator endpoint_it) {
void session_impl::connected(tcp::resolver::results_type::iterator endpoint_it) {
if (!setup_session()) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/asio_client_session_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class session_impl : public std::enable_shared_from_this<session_impl> {

void start_resolve(const std::string &host, const std::string &service);

void connected(tcp::resolver::iterator endpoint_it);
void connected(tcp::resolver::results_type::iterator endpoint_it);
void not_connected(const boost::system::error_code &ec);

void on_connect(connect_cb cb);
Expand All @@ -72,7 +72,7 @@ class session_impl : public std::enable_shared_from_this<session_impl> {
const std::string &method, const std::string &uri,
generator_cb cb, header_map h, priority_spec spec);

virtual void start_connect(tcp::resolver::iterator endpoint_it) = 0;
virtual void start_connect(tcp::resolver::results_type::iterator endpoint_it) = 0;
virtual tcp::socket &socket() = 0;
virtual void read_socket(
std::function<void(const boost::system::error_code &ec, std::size_t n)>
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_client_session_tcp_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ session_tcp_impl::session_tcp_impl(

session_tcp_impl::~session_tcp_impl() {}

void session_tcp_impl::start_connect(tcp::resolver::iterator endpoint_it) {
void session_tcp_impl::start_connect(tcp::resolver::results_type::iterator endpoint_it) {
auto self = shared_from_this();
socket_.async_connect(
*endpoint_it, [self, endpoint_it](const boost::system::error_code &ec) {
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_client_session_tcp_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class session_tcp_impl : public session_impl {
const boost::posix_time::time_duration &connect_timeout);
virtual ~session_tcp_impl();

virtual void start_connect(tcp::resolver::iterator endpoint_it);
virtual void start_connect(tcp::resolver::results_type::iterator endpoint_it);
virtual tcp::socket &socket();
virtual void read_socket(
std::function<void(const boost::system::error_code &ec, std::size_t n)>
Expand Down
11 changes: 5 additions & 6 deletions lib/asio_client_session_tls_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ session_tls_impl::session_tls_impl(
// this callback setting is no effect is
// ssl::context::set_verify_mode(boost::asio::ssl::verify_peer) is
// not used, which is what we want.
socket_.set_verify_callback(boost::asio::ssl::rfc2818_verification(host));
socket_.set_verify_callback(boost::asio::ssl::host_name_verification(host));
auto ssl = socket_.native_handle();
if (!util::numeric_host(host.c_str())) {
SSL_set_tlsext_host_name(ssl, host.c_str());
Expand All @@ -46,12 +46,12 @@ session_tls_impl::session_tls_impl(

session_tls_impl::~session_tls_impl() {}

void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
void session_tls_impl::start_connect(tcp::resolver::results_type::iterator endpoint_it) {
auto self = std::static_pointer_cast<session_tls_impl>(shared_from_this());
boost::asio::async_connect(
socket(), endpoint_it,
[self](const boost::system::error_code &ec,
tcp::resolver::iterator endpoint_it) {
tcp::resolver::results_type::iterator it) {
if (self->stopped()) {
return;
}
Expand All @@ -60,10 +60,9 @@ void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
self->not_connected(ec);
return;
}

self->socket_.async_handshake(
boost::asio::ssl::stream_base::client,
[self, endpoint_it](const boost::system::error_code &ec) {
[self, it](const boost::system::error_code &ec) {
if (self->stopped()) {
return;
}
Expand All @@ -79,7 +78,7 @@ void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
return;
}

self->connected(endpoint_it);
self->connected(it);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_client_session_tls_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class session_tls_impl : public session_impl {
const boost::posix_time::time_duration &connect_timeout);
virtual ~session_tls_impl();

virtual void start_connect(tcp::resolver::iterator endpoint_it);
virtual void start_connect(tcp::resolver::results_type::iterator endpoint_it);
virtual tcp::socket &socket();
virtual void read_socket(
std::function<void(const boost::system::error_code &ec, std::size_t n)>
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_io_service_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ io_service_pool::io_service_pool(std::size_t pool_size) : next_io_service_(0) {
// exit until they are explicitly stopped.
for (std::size_t i = 0; i < pool_size; ++i) {
auto io_service = std::make_shared<boost::asio::io_service>();
auto work = std::make_shared<boost::asio::io_service::work>(*io_service);
auto work = std::make_shared<boost::asio::io_context_work>(NGHTTP2_ASIO_IO_CONTEXT_WORK_PARAM(io_service));
io_services_.push_back(io_service);
work_.push_back(work);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_io_service_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class io_service_pool : private boost::noncopyable {
std::vector<std::shared_ptr<boost::asio::io_service>> io_services_;

/// The work that keeps the io_services running.
std::vector<std::shared_ptr<boost::asio::io_service::work>> work_;
std::vector<std::shared_ptr<boost::asio::io_context_work>> work_;

/// The next io_service to use for a connection.
std::size_t next_io_service_;
Expand Down
9 changes: 4 additions & 5 deletions lib/asio_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@ boost::system::error_code server::bind_and_listen(boost::system::error_code &ec,
// Open the acceptor with the option to reuse the address (i.e.
// SO_REUSEADDR).
tcp::resolver resolver(io_service_pool_.get_io_service());
tcp::resolver::query query(address, port);
auto it = resolver.resolve(query, ec);
auto results = resolver.resolve(address, port, ec);
if (ec) {
return ec;
}

for (; it != tcp::resolver::iterator(); ++it) {
tcp::endpoint endpoint = *it;
for (auto it : results) {
tcp::endpoint endpoint = it.endpoint();
auto acceptor = tcp::acceptor(io_service_pool_.get_io_service());

if (acceptor.open(endpoint.protocol(), ec)) {
Expand All @@ -103,7 +102,7 @@ boost::system::error_code server::bind_and_listen(boost::system::error_code &ec,
}

if (acceptor.listen(
backlog == -1 ? boost::asio::socket_base::max_connections : backlog,
backlog == -1 ? boost::asio::socket_base::max_listen_connections : backlog,
ec)) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/asio_server_http2_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void http2_handler::signal_write() {
if (!inside_callback_ && !write_signaled_) {
write_signaled_ = true;
auto self = shared_from_this();
io_service_.post([self]() { self->initiate_write(); });
boost::asio::post(io_service_, [self]() { self->initiate_write(); });
}
}

Expand Down
55 changes: 55 additions & 0 deletions lib/includes/nghttp2/asio_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,61 @@

#include <nghttp2/nghttp2.h>

namespace boost {
namespace asio {
#if BOOST_VERSION >= 108700

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The version check BOOST_VERSION >= 108700 seems too specific. The breaking changes in Boost.Asio that this compatibility layer addresses were introduced in Boost 1.86.0 (108600). The vcpkg patch this change is based on also uses 108600. Using 108700 will cause this code to fail with Boost 1.86. To ensure broader compatibility, including with Boost 1.86, please consider changing this to BOOST_VERSION >= 108600.

#if BOOST_VERSION >= 108600

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just some plausible-sounding crap which is in fact incorrect.

using io_service = boost::asio::io_context;
using const_buffers_1 = boost::asio::const_buffer;
using mutable_buffers_1 = boost::asio::mutable_buffer;
using io_context_work = boost::asio::executor_work_guard<boost::asio::io_context::executor_type>;
/// Cast a non-modifiable buffer to a specified pointer to POD type.
template <typename PointerToPodType>
inline PointerToPodType buffer_cast(const mutable_buffer& b) noexcept
{
return static_cast<PointerToPodType>(b.data());
}

/// Cast a non-modifiable buffer to a specified pointer to POD type.
template <typename PointerToPodType>
inline PointerToPodType buffer_cast(const const_buffer& b) noexcept
{
return static_cast<PointerToPodType>(b.data());
}

template <typename Protocol, typename Executor, typename Iterator,
BOOST_ASIO_COMPLETION_TOKEN_FOR(void (boost::system::error_code,
Iterator)) IteratorConnectToken = default_completion_token_t<Executor>>
inline auto async_connect(basic_socket<Protocol, Executor>& s, Iterator begin,
IteratorConnectToken&& token = default_completion_token_t<Executor>(),
constraint_t<
!is_endpoint_sequence<Iterator>::value
> = 0,
constraint_t<
!is_same<Iterator, decay_t<IteratorConnectToken>>::value
> = 0,
constraint_t<
!is_connect_condition<IteratorConnectToken, Iterator>::value
> = 0)
-> decltype(
async_initiate<IteratorConnectToken,
void (boost::system::error_code, Iterator)>(
declval<detail::initiate_async_iterator_connect<Protocol, Executor>>(),
token, begin, Iterator(),
declval<detail::default_connect_condition>()))
{
return async_initiate<IteratorConnectToken,
void (boost::system::error_code, Iterator)>(
detail::initiate_async_iterator_connect<Protocol, Executor>(s),
token, begin, Iterator(), detail::default_connect_condition());
}
#define NGHTTP2_ASIO_IO_CONTEXT_WORK_PARAM(IO_SERVICE) (IO_SERVICE)->get_executor()
#else
using io_context_work = boost::asio::io_service::work;
#define NGHTTP2_ASIO_IO_CONTEXT_WORK_PARAM(IO_SERVICE) *(IO_SERVICE)
#endif
}
}

namespace nghttp2 {

namespace asio_http2 {
Expand Down
2 changes: 1 addition & 1 deletion lib/includes/nghttp2/asio_http2_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class request;
using response_cb = std::function<void(const response &)>;
using request_cb = std::function<void(const request &)>;
using connect_cb =
std::function<void(boost::asio::ip::tcp::resolver::iterator)>;
std::function<void(boost::asio::ip::tcp::resolver::results_type::iterator)>;

class request_impl;

Expand Down