0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 11:18:51 +02:00

ircd::ctx: Detach context in dtor on main/async stacks.

This commit is contained in:
Jason Volk 2018-05-28 03:12:11 -07:00
parent 1f92aee9dd
commit c8902654a0

View file

@ -889,14 +889,12 @@ ircd::ctx::context::context(function func,
ircd::ctx::context::~context()
noexcept
{
if(!c)
return;
// Can't join to bare metal, only from within another context.
if(current)
if(c && current)
{
interrupt();
join();
return;
}
// because *this uses unique_ptr's, if we dtor the ircd::ctx from
@ -905,8 +903,17 @@ noexcept
// queue.
if(c && !started(*c))
{
c->flags |= context::DETACH;
c.release();
detach();
return;
}
// When this is bare metal the above join branch will not have been
// taken. In that case we should detach the context so it frees itself,
// but only if the context has not already finished.
if(c && !current && !finished(*c))
{
detach();
return;
}
}