File indexing completed on 2025-01-18 09:28:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_WIN_IOCP_WAIT_OP_HPP
0012 #define BOOST_ASIO_DETAIL_WIN_IOCP_WAIT_OP_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_IOCP)
0021
0022 #include <boost/asio/detail/bind_handler.hpp>
0023 #include <boost/asio/detail/buffer_sequence_adapter.hpp>
0024 #include <boost/asio/detail/fenced_block.hpp>
0025 #include <boost/asio/detail/handler_alloc_helpers.hpp>
0026 #include <boost/asio/detail/handler_work.hpp>
0027 #include <boost/asio/detail/memory.hpp>
0028 #include <boost/asio/detail/reactor_op.hpp>
0029 #include <boost/asio/detail/socket_ops.hpp>
0030 #include <boost/asio/error.hpp>
0031
0032 #include <boost/asio/detail/push_options.hpp>
0033
0034 namespace boost {
0035 namespace asio {
0036 namespace detail {
0037
0038 template <typename Handler, typename IoExecutor>
0039 class win_iocp_wait_op : public reactor_op
0040 {
0041 public:
0042 BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_wait_op);
0043
0044 win_iocp_wait_op(socket_ops::weak_cancel_token_type cancel_token,
0045 Handler& handler, const IoExecutor& io_ex)
0046 : reactor_op(boost::system::error_code(),
0047 &win_iocp_wait_op::do_perform,
0048 &win_iocp_wait_op::do_complete),
0049 cancel_token_(cancel_token),
0050 handler_(static_cast<Handler&&>(handler)),
0051 work_(handler_, io_ex)
0052 {
0053 }
0054
0055 static status do_perform(reactor_op*)
0056 {
0057 return done;
0058 }
0059
0060 static void do_complete(void* owner, operation* base,
0061 const boost::system::error_code& result_ec,
0062 std::size_t )
0063 {
0064 boost::system::error_code ec(result_ec);
0065
0066
0067 BOOST_ASIO_ASSUME(base != 0);
0068 win_iocp_wait_op* o(static_cast<win_iocp_wait_op*>(base));
0069 ptr p = { boost::asio::detail::addressof(o->handler_), o, o };
0070
0071 BOOST_ASIO_HANDLER_COMPLETION((*o));
0072
0073
0074 handler_work<Handler, IoExecutor> w(
0075 static_cast<handler_work<Handler, IoExecutor>&&>(
0076 o->work_));
0077
0078
0079 if (o->ec_)
0080 ec = o->ec_;
0081
0082
0083 if (ec.value() == ERROR_NETNAME_DELETED)
0084 {
0085 if (o->cancel_token_.expired())
0086 ec = boost::asio::error::operation_aborted;
0087 else
0088 ec = boost::asio::error::connection_reset;
0089 }
0090 else if (ec.value() == ERROR_PORT_UNREACHABLE)
0091 {
0092 ec = boost::asio::error::connection_refused;
0093 }
0094
0095 BOOST_ASIO_ERROR_LOCATION(ec);
0096
0097
0098
0099
0100
0101
0102
0103 detail::binder1<Handler, boost::system::error_code>
0104 handler(o->handler_, ec);
0105 p.h = boost::asio::detail::addressof(handler.handler_);
0106 p.reset();
0107
0108
0109 if (owner)
0110 {
0111 fenced_block b(fenced_block::half);
0112 BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_));
0113 w.complete(handler, handler.handler_);
0114 BOOST_ASIO_HANDLER_INVOCATION_END;
0115 }
0116 }
0117
0118 private:
0119 socket_ops::weak_cancel_token_type cancel_token_;
0120 Handler handler_;
0121 handler_work<Handler, IoExecutor> work_;
0122 };
0123
0124 }
0125 }
0126 }
0127
0128 #include <boost/asio/detail/pop_options.hpp>
0129
0130 #endif
0131
0132 #endif