Ensure basic_stream::close will not throw

refs: #1875
This commit is contained in:
Richard Hodges
2020-03-13 18:47:08 +01:00
parent a21c1b7298
commit 570eafcd40
3 changed files with 11 additions and 12 deletions

View File

@ -4,6 +4,7 @@ Version XXX:
* Refactor websocket read
* Correct buffer_bytes documentation
* Fix examples to dispatch to strand
* Ensure basic_stream::close will not throw
--------------------------------------------------------------------------------

View File

@ -291,8 +291,8 @@ private:
template<class Executor2>
void on_timer(Executor2 const& ex2);
void reset(); // set timeouts to never
void close(); // cancel everything
void reset(); // set timeouts to never
void close() noexcept; // cancel everything
};
// We use shared ownership for the state so it can

View File

@ -143,21 +143,19 @@ template<class Protocol, class Executor, class RatePolicy>
void
basic_stream<Protocol, Executor, RatePolicy>::
impl_type::
close()
close() noexcept
{
{
error_code ec;
socket.close(ec);
}
timer.cancel();
// have to let the read/write ops cancel the timer,
// otherwise we will get error::timeout on close when
// we actually want net::error::operation_aborted.
//
//read.timer.cancel();
//write.timer.cancel();
try
{
timer.cancel();
}
catch(...)
{
}
}
//------------------------------------------------------------------------------