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 * Refactor websocket read
* Correct buffer_bytes documentation * Correct buffer_bytes documentation
* Fix examples to dispatch to strand * Fix examples to dispatch to strand
* Ensure basic_stream::close will not throw
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

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

View File

@ -143,21 +143,19 @@ template<class Protocol, class Executor, class RatePolicy>
void void
basic_stream<Protocol, Executor, RatePolicy>:: basic_stream<Protocol, Executor, RatePolicy>::
impl_type:: impl_type::
close() close() noexcept
{ {
{ {
error_code ec; error_code ec;
socket.close(ec); socket.close(ec);
} }
try
{
timer.cancel(); timer.cancel();
}
catch(...)
// 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();
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------