From 57d55cebe410ecf301ca878c08c4152e931e23be Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 4 Sep 2013 11:55:38 -0700 Subject: [PATCH] Move UNL timer processing to the JobQueue --- .../peers/ripple_UniqueNodeList.cpp | 58 +++++++++++-------- modules/ripple_core/functional/ripple_Job.cpp | 1 + modules/ripple_core/functional/ripple_Job.h | 23 ++++---- 3 files changed, 48 insertions(+), 34 deletions(-) diff --git a/modules/ripple_app/peers/ripple_UniqueNodeList.cpp b/modules/ripple_app/peers/ripple_UniqueNodeList.cpp index 44737ec4e..39deee2ec 100644 --- a/modules/ripple_app/peers/ripple_UniqueNodeList.cpp +++ b/modules/ripple_app/peers/ripple_UniqueNodeList.cpp @@ -100,36 +100,48 @@ public: //-------------------------------------------------------------------------- + void doScore () + { + mtpScoreNext = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Timer not set. + mtpScoreStart = boost::posix_time::second_clock::universal_time (); // Scoring. + + WriteLog (lsTRACE, UniqueNodeList) << "Scoring: Start"; + + scoreCompute (); + + WriteLog (lsTRACE, UniqueNodeList) << "Scoring: End"; + + // Save update time. + mtpScoreUpdated = mtpScoreStart; + miscSave (); + + mtpScoreStart = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Not scoring. + + // Score again if needed. + scoreNext (false); + + // Scan may be dirty due to new ips. + getApp().getPeers ().scanRefresh (); + } + + void doFetch () + { + // Time to check for another fetch. + WriteLog (lsTRACE, UniqueNodeList) << "fetchTimerHandler"; + fetchNext (); + } + void onDeadlineTimer (DeadlineTimer& timer) { if (timer == m_scoreTimer) { - mtpScoreNext = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Timer not set. - mtpScoreStart = boost::posix_time::second_clock::universal_time (); // Scoring. - - WriteLog (lsTRACE, UniqueNodeList) << "Scoring: Start"; - - scoreCompute (); - - WriteLog (lsTRACE, UniqueNodeList) << "Scoring: End"; - - // Save update time. - mtpScoreUpdated = mtpScoreStart; - miscSave (); - - mtpScoreStart = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Not scoring. - - // Score again if needed. - scoreNext (false); - - // Scan may be dirty due to new ips. - getApp().getPeers ().scanRefresh (); + getApp().getJobQueue ().addJob (jtUNL, "UNL.score", + BIND_TYPE (&UniqueNodeListImp::doScore, this)); } else if (timer == m_fetchTimer) { - // Time to check for another fetch. - WriteLog (lsTRACE, UniqueNodeList) << "fetchTimerHandler"; - fetchNext (); + getApp().getJobQueue ().addJob (jtUNL, "UNL.fetch", + BIND_TYPE (&UniqueNodeListImp::doFetch, this)); } } diff --git a/modules/ripple_core/functional/ripple_Job.cpp b/modules/ripple_core/functional/ripple_Job.cpp index a77cba23d..c64a98638 100644 --- a/modules/ripple_core/functional/ripple_Job.cpp +++ b/modules/ripple_core/functional/ripple_Job.cpp @@ -66,6 +66,7 @@ const char* Job::toString (JobType t) case jtUPDATE_PF: return "updatePaths"; case jtCLIENT: return "clientCommand"; case jtTRANSACTION: return "transaction"; + case jtUNL: return "unl"; case jtADVANCE: return "advanceLedger"; case jtPUBLEDGER: return "publishNewLedger"; case jtTXN_DATA: return "fetchTxnData"; diff --git a/modules/ripple_core/functional/ripple_Job.h b/modules/ripple_core/functional/ripple_Job.h index 1edbd8c19..481fcf8c6 100644 --- a/modules/ripple_core/functional/ripple_Job.h +++ b/modules/ripple_core/functional/ripple_Job.h @@ -23,17 +23,18 @@ enum JobType jtUPDATE_PF = 8, // Update pathfinding requests jtCLIENT = 9, // A websocket command from the client jtTRANSACTION = 10, // A transaction received from the network - jtADVANCE = 11, // Advance validated/acquired ledgers - jtPUBLEDGER = 12, // Publish a fully-accepted ledger - jtTXN_DATA = 13, // Fetch a proposed set - jtWAL = 14, // Write-ahead logging - jtVALIDATION_t = 15, // A validation from a trusted source - jtWRITE = 16, // Write out hashed objects - jtPROPOSAL_t = 17, // A proposal from a trusted source - jtSWEEP = 18, // Sweep for stale structures - jtNETOP_CLUSTER = 19, // NetworkOPs cluster peer report - jtNETOP_TIMER = 20, // NetworkOPs net timer processing - jtADMIN = 21, // An administrative operation + jtUNL = 11, // A Score or Fetch of the UNL (DEPRECATED) + jtADVANCE = 12, // Advance validated/acquired ledgers + jtPUBLEDGER = 13, // Publish a fully-accepted ledger + jtTXN_DATA = 14, // Fetch a proposed set + jtWAL = 15, // Write-ahead logging + jtVALIDATION_t = 16, // A validation from a trusted source + jtWRITE = 17, // Write out hashed objects + jtPROPOSAL_t = 18, // A proposal from a trusted source + jtSWEEP = 19, // Sweep for stale structures + jtNETOP_CLUSTER = 20, // NetworkOPs cluster peer report + jtNETOP_TIMER = 21, // NetworkOPs net timer processing + jtADMIN = 22, // An administrative operation // special types not dispatched by the job pool jtPEER = 24,