From 52439ebb2dbbcec9049a4f65e5403a3aa87918d2 Mon Sep 17 00:00:00 2001 From: JCW Date: Thu, 25 Sep 2025 14:47:05 +0100 Subject: [PATCH] Fix edge case Signed-off-by: JCW --- src/xrpld/core/Coro.ipp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xrpld/core/Coro.ipp b/src/xrpld/core/Coro.ipp index eaa47fd41c..02eed4c709 100644 --- a/src/xrpld/core/Coro.ipp +++ b/src/xrpld/core/Coro.ipp @@ -96,6 +96,16 @@ JobQueue::Coro::yield() inline bool JobQueue::Coro::post() { + if (state_ == CoroState::Finished) + { + // The coroutine will run until it finishes if the JobQueue has stopped. + // In the case where make_shared() succeeds and then the JobQueue + // stops before coro_ gets executed, post() will still be called and + // state_ will be Finished. We should return false and avoid XRPL_ASSERT + // as it's a valid edge case. + return false; + } + XRPL_ASSERT( state_ == CoroState::Suspended, "JobQueue::Coro::post: coroutine should be suspended!");