Destroy abandoned websocket ops on shutdown

fix #1358
This commit is contained in:
Vinnie Falco
2019-02-27 16:27:42 -08:00
parent 72a99c43a7
commit 92ad50a8e7
6 changed files with 42 additions and 0 deletions

View File

@ -3,6 +3,7 @@ Version 223:
* Add test::stream::service
* Add websocket service
* Pausation abandoning test
* Destroy abandoned websocket ops on shutdown
--------------------------------------------------------------------------------

View File

@ -335,6 +335,8 @@
* ([issue 1306]) `test::stream`
has fewer dependencies
* ([issue 1358]) Destroy abandoned websocket ops on shutdown
* ([issue 1365]) Handler wrappers decay parameters sooner
* ([issue 1408]) `session_alloc`

View File

@ -39,6 +39,16 @@ operator=(saved_handler&& other) noexcept
return *this;
}
bool
saved_handler::
reset() noexcept
{
if(! p_)
return false;
boost::exchange(p_, nullptr)->destroy();
return true;
}
void
saved_handler::
invoke()

View File

@ -90,6 +90,16 @@ public:
void
emplace(Handler&& handler);
/** Discard the saved handler, if one exists.
If `*this` contains an object, it is destroyed.
@returns `true` if an object was destroyed.
*/
BOOST_BEAST_DECL
bool
reset() noexcept;
/** Unconditionally invoke the stored completion handler.
Requires `this->has_value() == true`. Any dynamic memory

View File

@ -55,6 +55,10 @@ public:
svc_.v_[index_] = &other;
svc_.v_.pop_back();
}
virtual
void
shutdown() = 0;
};
private:
@ -72,6 +76,9 @@ private:
for(auto p : v_)
v.emplace_back(p->weak_from_this());
}
for(auto wp : v)
if(auto sp = wp.lock())
sp->shutdown();
}
public:

View File

@ -138,6 +138,18 @@ struct stream<NextLayer, deflateSupported>::impl_type
timeout_opt.keep_alive_pings = false;
}
void
shutdown() override
{
op_rd.reset();
op_wr.reset();
op_ping.reset();
op_idle_ping.reset();
op_close.reset();
op_r_rd.reset();
op_r_close.reset();
}
void
open(role_type role_)
{