|
12 | 12 | #include <xrpl/basics/base64.h> |
13 | 13 | #include <xrpl/basics/contract.h> |
14 | 14 | #include <xrpl/basics/make_SSLContext.h> |
| 15 | +#include <xrpl/core/CoroTask.h> |
15 | 16 | #include <xrpl/beast/net/IPAddressConversion.h> |
16 | 17 | #include <xrpl/beast/rfc2616.h> |
17 | 18 | #include <xrpl/core/JobQueue.h> |
@@ -284,9 +285,10 @@ ServerHandler::onRequest(Session& session) |
284 | 285 | } |
285 | 286 |
|
286 | 287 | std::shared_ptr<Session> detachedSession = session.detach(); |
287 | | - auto const postResult = m_jobQueue.postCoro( |
288 | | - jtCLIENT_RPC, "RPC-Client", [this, detachedSession](std::shared_ptr<JobQueue::Coro> coro) { |
289 | | - processSession(detachedSession, coro); |
| 288 | + auto const postResult = m_jobQueue.postCoroTask( |
| 289 | + jtCLIENT_RPC, "RPC-Client", [this, detachedSession](auto) -> CoroTask<void> { |
| 290 | + processSession(detachedSession); |
| 291 | + co_return; |
290 | 292 | }); |
291 | 293 | if (postResult == nullptr) |
292 | 294 | { |
@@ -322,17 +324,18 @@ ServerHandler::onWSMessage( |
322 | 324 |
|
323 | 325 | JLOG(m_journal.trace()) << "Websocket received '" << jv << "'"; |
324 | 326 |
|
325 | | - auto const postResult = m_jobQueue.postCoro( |
| 327 | + auto const postResult = m_jobQueue.postCoroTask( |
326 | 328 | jtCLIENT_WEBSOCKET, |
327 | 329 | "WS-Client", |
328 | | - [this, session, jv = std::move(jv)](std::shared_ptr<JobQueue::Coro> const& coro) { |
329 | | - auto const jr = this->processSession(session, coro, jv); |
| 330 | + [this, session, jv = std::move(jv)](auto) -> CoroTask<void> { |
| 331 | + auto const jr = this->processSession(session, jv); |
330 | 332 | auto const s = to_string(jr); |
331 | 333 | auto const n = s.length(); |
332 | 334 | boost::beast::multi_buffer sb(n); |
333 | 335 | sb.commit(boost::asio::buffer_copy(sb.prepare(n), boost::asio::buffer(s.c_str(), n))); |
334 | 336 | session->send(std::make_shared<StreambufWSMsg<decltype(sb)>>(std::move(sb))); |
335 | 337 | session->complete(); |
| 338 | + co_return; |
336 | 339 | }); |
337 | 340 | if (postResult == nullptr) |
338 | 341 | { |
@@ -375,7 +378,6 @@ logDuration(Json::Value const& request, T const& duration, beast::Journal& journ |
375 | 378 | Json::Value |
376 | 379 | ServerHandler::processSession( |
377 | 380 | std::shared_ptr<WSSession> const& session, |
378 | | - std::shared_ptr<JobQueue::Coro> const& coro, |
379 | 381 | Json::Value const& jv) |
380 | 382 | { |
381 | 383 | auto is = std::static_pointer_cast<WSInfoSub>(session->appDefined); |
@@ -443,7 +445,6 @@ ServerHandler::processSession( |
443 | 445 | app_.getLedgerMaster(), |
444 | 446 | is->getConsumer(), |
445 | 447 | role, |
446 | | - coro, |
447 | 448 | is, |
448 | 449 | apiVersion}, |
449 | 450 | jv, |
@@ -514,18 +515,15 @@ ServerHandler::processSession( |
514 | 515 | return jr; |
515 | 516 | } |
516 | 517 |
|
517 | | -// Run as a coroutine. |
518 | 518 | void |
519 | 519 | ServerHandler::processSession( |
520 | | - std::shared_ptr<Session> const& session, |
521 | | - std::shared_ptr<JobQueue::Coro> coro) |
| 520 | + std::shared_ptr<Session> const& session) |
522 | 521 | { |
523 | 522 | processRequest( |
524 | 523 | session->port(), |
525 | 524 | buffers_to_string(session->request().body().data()), |
526 | 525 | session->remoteAddress().at_port(0), |
527 | 526 | makeOutput(*session), |
528 | | - coro, |
529 | 527 | forwardedFor(session->request()), |
530 | 528 | [&] { |
531 | 529 | auto const iter = session->request().find("X-User"); |
@@ -562,7 +560,6 @@ ServerHandler::processRequest( |
562 | 560 | std::string const& request, |
563 | 561 | beast::IP::Endpoint const& remoteIPAddress, |
564 | 562 | Output&& output, |
565 | | - std::shared_ptr<JobQueue::Coro> coro, |
566 | 563 | std::string_view forwardedFor, |
567 | 564 | std::string_view user) |
568 | 565 | { |
@@ -819,7 +816,6 @@ ServerHandler::processRequest( |
819 | 816 | app_.getLedgerMaster(), |
820 | 817 | usage, |
821 | 818 | role, |
822 | | - coro, |
823 | 819 | InfoSub::pointer(), |
824 | 820 | apiVersion}, |
825 | 821 | params, |
|
0 commit comments