diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp | 87 |
1 files changed, 77 insertions, 10 deletions
diff --git a/3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp b/3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp index a1ee09a..dff0a82 100644 --- a/3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp +++ b/3rdParty/Boost/src/boost/asio/detail/impl/reactive_descriptor_service.ipp @@ -2,7 +2,7 @@ // detail/impl/reactive_descriptor_service.ipp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2012 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) @@ -46,11 +46,47 @@ void reactive_descriptor_service::construct( impl.state_ = 0; } +void reactive_descriptor_service::move_construct( + reactive_descriptor_service::implementation_type& impl, + reactive_descriptor_service::implementation_type& other_impl) +{ + impl.descriptor_ = other_impl.descriptor_; + other_impl.descriptor_ = -1; + + impl.state_ = other_impl.state_; + other_impl.state_ = 0; + + reactor_.move_descriptor(impl.descriptor_, + impl.reactor_data_, other_impl.reactor_data_); +} + +void reactive_descriptor_service::move_assign( + reactive_descriptor_service::implementation_type& impl, + reactive_descriptor_service& other_service, + reactive_descriptor_service::implementation_type& other_impl) +{ + destroy(impl); + + impl.descriptor_ = other_impl.descriptor_; + other_impl.descriptor_ = -1; + + impl.state_ = other_impl.state_; + other_impl.state_ = 0; + + other_service.reactor_.move_descriptor(impl.descriptor_, + impl.reactor_data_, other_impl.reactor_data_); +} + void reactive_descriptor_service::destroy( reactive_descriptor_service::implementation_type& impl) { if (is_open(impl)) - reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_); + { + BOOST_ASIO_HANDLER_OPERATION(("descriptor", &impl, "close")); + + reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_, + (impl.state_ & descriptor_ops::possible_dup) == 0); + } boost::system::error_code ignored_ec; descriptor_ops::close(impl.descriptor_, impl.state_, ignored_ec); @@ -58,7 +94,7 @@ void reactive_descriptor_service::destroy( boost::system::error_code reactive_descriptor_service::assign( reactive_descriptor_service::implementation_type& impl, - const native_type& native_descriptor, boost::system::error_code& ec) + const native_handle_type& native_descriptor, boost::system::error_code& ec) { if (is_open(impl)) { @@ -75,7 +111,7 @@ boost::system::error_code reactive_descriptor_service::assign( } impl.descriptor_ = native_descriptor; - impl.state_ = 0; + impl.state_ = descriptor_ops::possible_dup; ec = boost::system::error_code(); return ec; } @@ -85,14 +121,43 @@ boost::system::error_code reactive_descriptor_service::close( boost::system::error_code& ec) { if (is_open(impl)) - reactor_.close_descriptor(impl.descriptor_, impl.reactor_data_); + { + BOOST_ASIO_HANDLER_OPERATION(("descriptor", &impl, "close")); - if (descriptor_ops::close(impl.descriptor_, impl.state_, ec) == 0) - construct(impl); + reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_, + (impl.state_ & descriptor_ops::possible_dup) == 0); + } + + descriptor_ops::close(impl.descriptor_, impl.state_, ec); + + // The descriptor is closed by the OS even if close() returns an error. + // + // (Actually, POSIX says the state of the descriptor is unspecified. On + // Linux the descriptor is apparently closed anyway; e.g. see + // http://lkml.org/lkml/2005/9/10/129 + // We'll just have to assume that other OSes follow the same behaviour.) + construct(impl); return ec; } +reactive_descriptor_service::native_handle_type +reactive_descriptor_service::release( + reactive_descriptor_service::implementation_type& impl) +{ + native_handle_type descriptor = impl.descriptor_; + + if (is_open(impl)) + { + BOOST_ASIO_HANDLER_OPERATION(("descriptor", &impl, "release")); + + reactor_.deregister_descriptor(impl.descriptor_, impl.reactor_data_, false); + construct(impl); + } + + return descriptor; +} + boost::system::error_code reactive_descriptor_service::cancel( reactive_descriptor_service::implementation_type& impl, boost::system::error_code& ec) @@ -103,6 +168,8 @@ boost::system::error_code reactive_descriptor_service::cancel( return ec; } + BOOST_ASIO_HANDLER_OPERATION(("descriptor", &impl, "cancel")); + reactor_.cancel_ops(impl.descriptor_, impl.reactor_data_); ec = boost::system::error_code(); return ec; @@ -110,16 +177,16 @@ boost::system::error_code reactive_descriptor_service::cancel( void reactive_descriptor_service::start_op( reactive_descriptor_service::implementation_type& impl, - int op_type, reactor_op* op, bool non_blocking, bool noop) + int op_type, reactor_op* op, bool is_non_blocking, bool noop) { if (!noop) { if ((impl.state_ & descriptor_ops::non_blocking) || descriptor_ops::set_internal_non_blocking( - impl.descriptor_, impl.state_, op->ec_)) + impl.descriptor_, impl.state_, true, op->ec_)) { reactor_.start_op(op_type, impl.descriptor_, - impl.reactor_data_, op, non_blocking); + impl.reactor_data_, op, is_non_blocking); return; } } |