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:
parent
1f92aee9dd
commit
c8902654a0
1 changed files with 13 additions and 6 deletions
19
ircd/ctx.cc
19
ircd/ctx.cc
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue