Skip to content

Commit

Permalink
Clean up socket release() implementation for reactor-based platforms.
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Jul 29, 2017
1 parent f5c5708 commit b37b944
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions asio/include/asio/detail/impl/reactive_socket_service_base.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,19 @@ socket_type reactive_socket_service_base::release(
asio::error_code& ec)
{
if (!is_open(impl))
{
ec = asio::error::bad_descriptor;
return invalid_socket;
}

cancel(impl, ec);
if (ec)
return invalid_socket;

reactor_.deregister_descriptor(impl.socket_, impl.reactor_data_,
(impl.state_ & socket_ops::possible_dup) == 0);
ASIO_HANDLER_OPERATION((reactor_.context(),
"socket", &impl, impl.socket_, "release"));

socket_type tmp = impl.socket_;
impl.socket_ = invalid_socket;
return tmp;
reactor_.deregister_descriptor(impl.socket_, impl.reactor_data_, false);
socket_type sock = impl.socket_;
construct(impl);
ec = asio::error_code();
return sock;
}

asio::error_code reactive_socket_service_base::cancel(
Expand Down

0 comments on commit b37b944

Please sign in to comment.