mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Close download socket before result is passed to the callback:
* Specifically relevent to the processing of UNL downloads via ValidatorSite.
This commit is contained in:
committed by
manojsdoshi
parent
3bf0b724a3
commit
1577c775b3
@@ -97,6 +97,10 @@ public:
|
||||
|
||||
void
|
||||
onResponse(error_code const& ec);
|
||||
|
||||
private:
|
||||
void
|
||||
close();
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -125,6 +129,7 @@ WorkBase<Impl>::~WorkBase()
|
||||
if (cb_)
|
||||
cb_(make_error_code(boost::system::errc::not_a_socket),
|
||||
std::move(res_));
|
||||
close();
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
@@ -228,11 +233,26 @@ WorkBase<Impl>::onResponse(error_code const& ec)
|
||||
if (ec)
|
||||
return fail(ec);
|
||||
|
||||
close();
|
||||
assert(cb_);
|
||||
cb_(ec, std::move(res_));
|
||||
cb_ = nullptr;
|
||||
}
|
||||
|
||||
template <class Impl>
|
||||
void
|
||||
WorkBase<Impl>::close()
|
||||
{
|
||||
if (socket_.is_open())
|
||||
{
|
||||
error_code ec;
|
||||
socket_.shutdown(boost::asio::socket_base::shutdown_send, ec);
|
||||
if (ec)
|
||||
return;
|
||||
socket_.close(ec);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
Reference in New Issue
Block a user