From 3d6e76046cfae9f310d5a1ac18f6437d03a98753 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 17 Jun 2015 12:39:28 -0700 Subject: [PATCH] Always use co-routines: This permits RPC handlers to suspend and reschedule: --- src/ripple/rpc/Yield.h | 5 ----- src/ripple/rpc/impl/Yield.cpp | 3 --- src/ripple/server/impl/ServerHandlerImp.cpp | 24 ++++++--------------- 3 files changed, 6 insertions(+), 26 deletions(-) diff --git a/src/ripple/rpc/Yield.h b/src/ripple/rpc/Yield.h index 73dffafbc0..f7e0aaa9ea 100644 --- a/src/ripple/rpc/Yield.h +++ b/src/ripple/rpc/Yield.h @@ -78,15 +78,10 @@ private: struct YieldStrategy { enum class Streaming {no, yes}; - enum class UseCoroutines {no, yes}; /** Is the data streamed, or generated monolithically? */ Streaming streaming = Streaming::no; - /** Are results generated in a coroutine? If this is no, then the code can - never yield. */ - UseCoroutines useCoroutines = UseCoroutines::no; - /** How many bytes do we emit before yielding? 0 means "never yield due to number of bytes sent". */ std::size_t byteYieldCount = 0; diff --git a/src/ripple/rpc/impl/Yield.cpp b/src/ripple/rpc/impl/Yield.cpp index b604e787e7..55406603f3 100644 --- a/src/ripple/rpc/impl/Yield.cpp +++ b/src/ripple/rpc/impl/Yield.cpp @@ -70,9 +70,6 @@ YieldStrategy makeYieldStrategy (Section const& s) ys.streaming = get (s, "streaming") ? YieldStrategy::Streaming::yes : YieldStrategy::Streaming::no; - ys.useCoroutines = get (s, "use_coroutines") ? - YieldStrategy::UseCoroutines::yes : - YieldStrategy::UseCoroutines::no; ys.byteYieldCount = get (s, "byte_yield_count"); ys.accountYieldCount = get (s, "account_yield_count"); ys.transactionYieldCount = get (s, "transaction_yield_count"); diff --git a/src/ripple/server/impl/ServerHandlerImp.cpp b/src/ripple/server/impl/ServerHandlerImp.cpp index b1628ae521..f962985eea 100644 --- a/src/ripple/server/impl/ServerHandlerImp.cpp +++ b/src/ripple/server/impl/ServerHandlerImp.cpp @@ -181,24 +181,12 @@ ServerHandlerImp::onRequest (HTTP::Session& session) auto detach = session.detach(); - if (setup_.yieldStrategy.useCoroutines == - RPC::YieldStrategy::UseCoroutines::yes) - { - RPC::SuspendCallback suspend ( - [this, detach] (RPC::Suspend const& suspend) { - processSession (detach, suspend); - }); - RPC::Coroutine coroutine (suspend); - coroutine.run(); - } - else - { - m_jobQueue.addJob ( - jtCLIENT, "RPC-Client", - [=] (Job&) { - processSession (detach, RPC::Suspend()); - }); - } + RPC::SuspendCallback suspend ( + [this, detach] (RPC::Suspend const& suspend) { + processSession (detach, suspend); + }); + RPC::Coroutine coroutine (suspend); + coroutine.run(); } void