From ccf5b79e6af86c78d66d07fdc424217fcaf814e2 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 19 Aug 2018 17:43:25 -0700 Subject: [PATCH] ircd::ctx: Allow this_ctx::interruption toggle to no-op if no ctx. --- ircd/ctx.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ircd/ctx.cc b/ircd/ctx.cc index c5db4a794..b87541e99 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -565,21 +565,31 @@ ircd::ctx::this_ctx::stack_at_here() /// Throws interrupted if the currently running context was interrupted /// and clears the interrupt flag. +/// +/// Unlike most of this_ctx::, this function is a no-op if not currently +/// on a context. void ircd::ctx::this_ctx::interruptible(const bool &b) { - interruptible(b, std::nothrow); - interruption_point(); + if(likely(current)) + { + interruptible(cur(), b); + interruption_point(); + } } /// Throws interrupted if the currently running context was interrupted /// and clears the interrupt flag. +/// +/// Unlike most of this_ctx::, this function is a no-op if not currently +/// on a context. void ircd::ctx::this_ctx::interruptible(const bool &b, std::nothrow_t) noexcept { - interruptible(cur(), b); + if(likely(current)) + interruptible(cur(), b); } /// Throws interrupted if the currently running context was interrupted