Squashed 'Sources/OpenVPNAdapter/Libraries/Vendors/asio/' changes from 90f32660cd..8d4c8c3ce4

8d4c8c3ce4 asio version 1.14.0 released
30336a0873 Revision history.
2a1f68845a On Windows, ensure global object destructors are run.
6f55aeecd0 Fix move-based async_accept between sockets with different executor types.
c1c068c6ad The executor is copied, not moved, when the I/O object moves.
37c8d91d21 Add runtime detection of native I/O executors when using polymorphic wrapper.

git-subtree-dir: Sources/OpenVPNAdapter/Libraries/Vendors/asio
git-subtree-split: 8d4c8c3ce43c866f609d2eda9a43fe5b334620be
This commit is contained in:
Sergey Abramchuk
2019-10-25 20:20:10 +03:00
parent 9ec9e579e9
commit f44694ce5f
9 changed files with 83 additions and 25 deletions

View File

@@ -24,8 +24,34 @@
#include "asio/detail/push_options.hpp"
namespace asio {
class executor;
namespace detail {
inline bool is_native_io_executor(const io_context::executor_type&)
{
return true;
}
template <typename Executor>
inline bool is_native_io_executor(const Executor&,
typename enable_if<!is_same<Executor, executor>::value>::type* = 0)
{
return false;
}
template <typename Executor>
inline bool is_native_io_executor(const Executor& ex,
typename enable_if<is_same<Executor, executor>::value>::type* = 0)
{
#if !defined (ASIO_NO_TYPEID)
return ex.target_type() == typeid(io_context::executor_type);
#else // !defined (ASIO_NO_TYPEID)
return false;
#endif // !defined (ASIO_NO_TYPEID)
}
template <typename IoObjectService,
typename Executor = io_context::executor_type>
class io_object_impl
@@ -46,8 +72,7 @@ public:
// Construct an I/O object using an executor.
explicit io_object_impl(const executor_type& ex)
: service_(&asio::use_service<IoObjectService>(ex.context())),
implementation_executor_(ex,
is_same<Executor, io_context::executor_type>::value)
implementation_executor_(ex, (is_native_io_executor)(ex))
{
service_->construct(implementation_);
}
@@ -68,9 +93,7 @@ public:
// Move-construct an I/O object.
io_object_impl(io_object_impl&& other)
: service_(&other.get_service()),
implementation_executor_(
ASIO_MOVE_CAST(implementation_executor_type)(
other.implementation_executor_))
implementation_executor_(other.get_implementation_executor())
{
service_->move_construct(implementation_, other.implementation_);
}

View File

@@ -151,8 +151,10 @@ private:
template <typename Protocol, typename PeerIoExecutor,
typename Handler, typename IoExecutor>
class reactive_socket_move_accept_op :
private Protocol::socket,
public reactive_socket_accept_op_base<typename Protocol::socket, Protocol>
private Protocol::socket::template rebind_executor<PeerIoExecutor>::other,
public reactive_socket_accept_op_base<
typename Protocol::socket::template rebind_executor<PeerIoExecutor>::other,
Protocol>
{
public:
ASIO_DEFINE_HANDLER_PTR(reactive_socket_move_accept_op);
@@ -161,8 +163,8 @@ public:
socket_type socket, socket_ops::state_type state,
const Protocol& protocol, typename Protocol::endpoint* peer_endpoint,
Handler& handler, const IoExecutor& io_ex)
: Protocol::socket(peer_io_ex),
reactive_socket_accept_op_base<typename Protocol::socket, Protocol>(
: peer_socket_type(peer_io_ex),
reactive_socket_accept_op_base<peer_socket_type, Protocol>(
socket, state, *this, protocol, peer_endpoint,
&reactive_socket_move_accept_op::do_complete),
handler_(ASIO_MOVE_CAST(Handler)(handler)),
@@ -194,9 +196,9 @@ public:
// to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here.
detail::move_binder2<Handler,
asio::error_code, typename Protocol::socket>
asio::error_code, peer_socket_type>
handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), o->ec_,
ASIO_MOVE_CAST(typename Protocol::socket)(*o));
ASIO_MOVE_CAST(peer_socket_type)(*o));
p.h = asio::detail::addressof(handler.handler_);
p.reset();
@@ -211,6 +213,9 @@ public:
}
private:
typedef typename Protocol::socket::template
rebind_executor<PeerIoExecutor>::other peer_socket_type;
Handler handler_;
IoExecutor io_executor_;
};

View File

@@ -35,7 +35,7 @@ struct win_global_impl
static win_global_impl instance_;
static static_mutex mutex_;
static T* ptr_;
T* ptr_;
static tss_ptr<T> tss_ptr_;
};
@@ -45,9 +45,6 @@ win_global_impl<T> win_global_impl<T>::instance_ = { 0 };
template <typename T>
static_mutex win_global_impl<T>::mutex_ = ASIO_STATIC_MUTEX_INIT;
template <typename T>
T* win_global_impl<T>::ptr_ = 0;
template <typename T>
tss_ptr<T> win_global_impl<T>::tss_ptr_;
@@ -58,9 +55,9 @@ T& win_global()
{
win_global_impl<T>::mutex_.init();
static_mutex::scoped_lock lock(win_global_impl<T>::mutex_);
if (win_global_impl<T>::ptr_ == 0)
win_global_impl<T>::ptr_ = new T;
win_global_impl<T>::tss_ptr_ = win_global_impl<T>::ptr_;
if (win_global_impl<T>::instance_.ptr_ == 0)
win_global_impl<T>::instance_.ptr_ = new T;
win_global_impl<T>::tss_ptr_ = win_global_impl<T>::instance_.ptr_;
}
return *win_global_impl<T>::tss_ptr_;

View File

@@ -262,9 +262,9 @@ public:
// to ensure that any owning sub-object remains valid until after we have
// deallocated the memory here.
detail::move_binder2<Handler,
asio::error_code, typename Protocol::socket>
asio::error_code, peer_socket_type>
handler(0, ASIO_MOVE_CAST(Handler)(o->handler_), ec,
ASIO_MOVE_CAST(typename Protocol::socket)(o->peer_));
ASIO_MOVE_CAST(peer_socket_type)(o->peer_));
p.h = asio::detail::addressof(handler.handler_);
p.reset();
@@ -279,10 +279,13 @@ public:
}
private:
typedef typename Protocol::socket::template
rebind_executor<PeerIoExecutor>::other peer_socket_type;
win_iocp_socket_service_base& socket_service_;
socket_type socket_;
socket_holder new_socket_;
typename Protocol::socket peer_;
peer_socket_type peer_;
Protocol protocol_;
typename Protocol::endpoint* peer_endpoint_;
unsigned char output_buffer_[(sizeof(sockaddr_storage_type) + 16) * 2];

View File

@@ -18,6 +18,6 @@
// ASIO_VERSION % 100 is the sub-minor version
// ASIO_VERSION / 100 % 1000 is the minor version
// ASIO_VERSION / 100000 is the major version
#define ASIO_VERSION 101300 // 1.13.0
#define ASIO_VERSION 101400 // 1.14.0
#endif // ASIO_VERSION_HPP