diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp b/3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp index 79580de..f5f0223 100644 --- a/3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp +++ b/3rdParty/Boost/src/boost/asio/detail/win_iocp_socket_service_base.hpp @@ -2,7 +2,7 @@ // detail/win_iocp_socket_service_base.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2014 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,11 +19,10 @@ #if defined(BOOST_ASIO_HAS_IOCP) -#include <boost/type_traits/is_same.hpp> -#include <boost/utility/addressof.hpp> #include <boost/asio/error.hpp> #include <boost/asio/io_service.hpp> #include <boost/asio/socket_base.hpp> +#include <boost/asio/detail/addressof.hpp> #include <boost/asio/detail/bind_handler.hpp> #include <boost/asio/detail/buffer_sequence_adapter.hpp> #include <boost/asio/detail/fenced_block.hpp> @@ -38,6 +37,7 @@ #include <boost/asio/detail/socket_types.hpp> #include <boost/asio/detail/win_iocp_io_service.hpp> #include <boost/asio/detail/win_iocp_null_buffers_op.hpp> +#include <boost/asio/detail/win_iocp_socket_connect_op.hpp> #include <boost/asio/detail/win_iocp_socket_send_op.hpp> #include <boost/asio/detail/win_iocp_socket_recv_op.hpp> #include <boost/asio/detail/win_iocp_socket_recvmsg_op.hpp> @@ -216,11 +216,11 @@ public: template <typename ConstBufferSequence, typename Handler> void async_send(base_implementation_type& impl, const ConstBufferSequence& buffers, - socket_base::message_flags flags, Handler handler) + socket_base::message_flags flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.cancel_token_, buffers, handler); @@ -239,11 +239,11 @@ public: // Start an asynchronous wait until data can be sent without blocking. template <typename Handler> void async_send(base_implementation_type& impl, const null_buffers&, - socket_base::message_flags, Handler handler) + socket_base::message_flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_null_buffers_op<Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.cancel_token_, handler); @@ -283,11 +283,11 @@ public: template <typename MutableBufferSequence, typename Handler> void async_receive(base_implementation_type& impl, const MutableBufferSequence& buffers, - socket_base::message_flags flags, Handler handler) + socket_base::message_flags flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_socket_recv_op<MutableBufferSequence, Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.state_, impl.cancel_token_, buffers, handler); @@ -306,11 +306,11 @@ public: // Wait until data can be received without blocking. template <typename Handler> void async_receive(base_implementation_type& impl, const null_buffers&, - socket_base::message_flags flags, Handler handler) + socket_base::message_flags flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_null_buffers_op<Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.cancel_token_, handler); @@ -357,11 +357,11 @@ public: template <typename MutableBufferSequence, typename Handler> void async_receive_with_flags(base_implementation_type& impl, const MutableBufferSequence& buffers, socket_base::message_flags in_flags, - socket_base::message_flags& out_flags, Handler handler) + socket_base::message_flags& out_flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_socket_recvmsg_op<MutableBufferSequence, Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.cancel_token_, buffers, out_flags, handler); @@ -380,11 +380,11 @@ public: template <typename Handler> void async_receive_with_flags(base_implementation_type& impl, const null_buffers&, socket_base::message_flags in_flags, - socket_base::message_flags& out_flags, Handler handler) + socket_base::message_flags& out_flags, Handler& handler) { // Allocate and construct an operation to wrap the handler. typedef win_iocp_null_buffers_op<Handler> op; - typename op::ptr p = { boost::addressof(handler), + typename op::ptr p = { boost::asio::detail::addressof(handler), boost_asio_handler_alloc_helpers::allocate( sizeof(op), handler), 0 }; p.p = new (p.v) op(impl.cancel_token_, handler); @@ -446,13 +446,14 @@ protected: bool peer_is_open, socket_holder& new_socket, int family, int type, int protocol, void* output_buffer, DWORD address_length, operation* op); - // Start an asynchronous read or write operation using the the reactor. + // Start an asynchronous read or write operation using the reactor. BOOST_ASIO_DECL void start_reactor_op(base_implementation_type& impl, int op_type, reactor_op* op); // Start the asynchronous connect operation using the reactor. BOOST_ASIO_DECL void start_connect_op(base_implementation_type& impl, - reactor_op* op, const socket_addr_type* addr, std::size_t addrlen); + int family, int type, const socket_addr_type* remote_addr, + std::size_t remote_addrlen, win_iocp_socket_connect_op_base* op); // Helper function to close a socket when the associated object is being // destroyed. @@ -467,6 +468,16 @@ protected: // this service. BOOST_ASIO_DECL reactor& get_reactor(); + // The type of a ConnectEx function pointer, as old SDKs may not provide it. + typedef BOOL (PASCAL *connect_ex_fn)(SOCKET, + const socket_addr_type*, int, void*, DWORD, DWORD*, OVERLAPPED*); + + // Helper function to get the ConnectEx pointer. If no ConnectEx pointer has + // been obtained yet, one is obtained using WSAIoctl and the pointer is + // cached. Returns a null pointer if ConnectEx is not available. + BOOST_ASIO_DECL connect_ex_fn get_connect_ex( + base_implementation_type& impl, int type); + // Helper function to emulate InterlockedCompareExchangePointer functionality // for: // - very old Platform SDKs; and @@ -490,6 +501,9 @@ protected: // only if needed. reactor* reactor_; + // Pointer to ConnectEx implementation. + void* connect_ex_; + // Mutex to protect access to the linked list of implementations. boost::asio::detail::mutex mutex_; |