From f17f9685ec46b108b1dde85ba756a75f487b477b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 22 May 2018 00:18:46 -0700 Subject: [PATCH] ircd::ctx::ole: Use interrupt suppression scope while offloaded. --- ircd/ctx.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ircd/ctx.cc b/ircd/ctx.cc index e015399de..6dc7438c5 100644 --- a/ircd/ctx.cc +++ b/ircd/ctx.cc @@ -1293,13 +1293,22 @@ ircd::ctx::ole::offload(const std::function &func) signal(*context, kick); }); + // interrupt(ctx) is suppressed while this context has offloaded some work + // to another thread. This context must stay right here and not disappear + // until the other thread signals back. Note that the destructor is + // capable of throwing an interrupt that was received during this scope. + const this_ctx::uninterruptible uninterruptible; + push(std::move(closure)); do { wait(); } while(!done); - if(eptr) + // Don't throw any exception if there is a pending interrupt for this ctx. + // Two exceptions will be thrown in that case and if there's an interrupt + // we don't care about eptr anyway. + if(eptr && likely(!interruption_requested())) std::rethrow_exception(eptr); }