From 6fbd29b1ed5aebfe4661b4cf83998ebe6bba0fdc Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 26 Mar 2019 14:49:43 -0700 Subject: [PATCH] ircd::ctx: Add context::WAIT_JOIN feature flag. --- include/ircd/ctx/context.h | 1 + ircd/ctx.cc | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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; }