diff --git a/include/ircd/ctx/context.h b/include/ircd/ctx/context.h index b92e7b697..9e07779c8 100644 --- a/include/ircd/ctx/context.h +++ b/include/ircd/ctx/context.h @@ -104,6 +104,7 @@ enum ircd::ctx::context::flags NOINTERRUPT = 0x0008, ///< Interruption points won't throw while lit. SLICE_EXEMPT = 0x0010, ///< The watchdog will ignore excessive cpu usage. STACK_EXEMPT = 0x0020, ///< The watchdog will ignore excessive stack usage. + WAIT_JOIN = 0x0040, ///< Destruction of instance won't terminate ctx. INTERRUPTED = 0x4000, ///< (INDICATOR) Marked TERMINATED = 0x8000, ///< (INDICATOR) diff --git a/ircd/ctx.cc b/ircd/ctx.cc index 3ced7eb15..c32c1b46b 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -1221,7 +1221,12 @@ noexcept if(current) { const uninterruptible::nothrow ui; - terminate(); + + // When the WAIT_JOIN flag is given we wait for the context to + // complete cooperatively before this destructs. + if(~c->flags & context::WAIT_JOIN) + terminate(); + join(); return; }