X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fasio%2Fdetail%2Freactive_socket_recvfrom_op.hpp;h=b91dd02a65f580582721bd207124fbb93ed851b3;hb=20effc670b57271cb089376d6d0800990e5218d5;hp=9f641d58e0c3aefe0e02584644f002f7b92115f1;hpb=a71831dadd1e1f3e0fa70405511f65cc33db0498;p=ceph.git diff --git a/ceph/src/boost/boost/asio/detail/reactive_socket_recvfrom_op.hpp b/ceph/src/boost/boost/asio/detail/reactive_socket_recvfrom_op.hpp index 9f641d58e..b91dd02a6 100644 --- a/ceph/src/boost/boost/asio/detail/reactive_socket_recvfrom_op.hpp +++ b/ceph/src/boost/boost/asio/detail/reactive_socket_recvfrom_op.hpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -33,10 +36,12 @@ template class reactive_socket_recvfrom_op_base : public reactor_op { public: - reactive_socket_recvfrom_op_base(socket_type socket, int protocol_type, + reactive_socket_recvfrom_op_base(const boost::system::error_code& success_ec, + socket_type socket, int protocol_type, const MutableBufferSequence& buffers, Endpoint& endpoint, socket_base::message_flags flags, func_type complete_func) - : reactor_op(&reactive_socket_recvfrom_op_base::do_perform, complete_func), + : reactor_op(success_ec, + &reactive_socket_recvfrom_op_base::do_perform, complete_func), socket_(socket), protocol_type_(protocol_type), buffers_(buffers), @@ -50,14 +55,27 @@ public: reactive_socket_recvfrom_op_base* o( static_cast(base)); - buffer_sequence_adapter bufs(o->buffers_); + typedef buffer_sequence_adapter bufs_type; std::size_t addr_len = o->sender_endpoint_.capacity(); - status result = socket_ops::non_blocking_recvfrom(o->socket_, - bufs.buffers(), bufs.count(), o->flags_, - o->sender_endpoint_.data(), &addr_len, - o->ec_, o->bytes_transferred_) ? done : not_done; + status result; + if (bufs_type::is_single_buffer) + { + result = socket_ops::non_blocking_recvfrom1( + o->socket_, bufs_type::first(o->buffers_).data(), + bufs_type::first(o->buffers_).size(), o->flags_, + o->sender_endpoint_.data(), &addr_len, + o->ec_, o->bytes_transferred_) ? done : not_done; + } + else + { + bufs_type bufs(o->buffers_); + result = socket_ops::non_blocking_recvfrom(o->socket_, + bufs.buffers(), bufs.count(), o->flags_, + o->sender_endpoint_.data(), &addr_len, + o->ec_, o->bytes_transferred_) ? done : not_done; + } if (result && !o->ec_) o->sender_endpoint_.resize(addr_len); @@ -84,17 +102,17 @@ class reactive_socket_recvfrom_op : public: BOOST_ASIO_DEFINE_HANDLER_PTR(reactive_socket_recvfrom_op); - reactive_socket_recvfrom_op(socket_type socket, int protocol_type, + reactive_socket_recvfrom_op(const boost::system::error_code& success_ec, + socket_type socket, int protocol_type, const MutableBufferSequence& buffers, Endpoint& endpoint, socket_base::message_flags flags, Handler& handler, const IoExecutor& io_ex) : reactive_socket_recvfrom_op_base( - socket, protocol_type, buffers, endpoint, flags, + success_ec, socket, protocol_type, buffers, endpoint, flags, &reactive_socket_recvfrom_op::do_complete), handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)), - io_executor_(io_ex) + work_(handler_, io_ex) { - handler_work::start(handler_, io_executor_); } static void do_complete(void* owner, operation* base, @@ -105,10 +123,14 @@ public: reactive_socket_recvfrom_op* o( static_cast(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; - handler_work w(o->handler_, o->io_executor_); BOOST_ASIO_HANDLER_COMPLETION((*o)); + // Take ownership of the operation's outstanding work. + handler_work w( + BOOST_ASIO_MOVE_CAST2(handler_work)( + o->work_)); + // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated @@ -132,7 +154,7 @@ public: private: Handler handler_; - IoExecutor io_executor_; + handler_work work_; }; } // namespace detail