mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::ctx::ole: Use interrupt suppression scope while offloaded.
This commit is contained in:
parent
7e8ec1ca63
commit
f17f9685ec
1 changed files with 10 additions and 1 deletions
11
ircd/ctx.cc
11
ircd/ctx.cc
|
@ -1293,13 +1293,22 @@ ircd::ctx::ole::offload(const std::function<void ()> &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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue