diff --git a/src/Application.cpp b/src/Application.cpp index 89fe9d2ddc..daac98dd54 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -38,7 +38,7 @@ DatabaseCon::~DatabaseCon() Application::Application() : mUNL(mIOService), mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300), - mSNTPClient(mIOService), mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), + mSNTPClient(mAuxService), mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL), mConnectionPool(mIOService), mPeerDoor(NULL), mRPCDoor(NULL) { @@ -51,6 +51,7 @@ extern int RpcDBCount, TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount void Application::stop() { + mAuxService.stop(); mIOService.stop(); mHashedObjectStore.bulkWrite(); mValidations.flush(); @@ -69,6 +70,11 @@ void Application::run() if (!theConfig.DEBUG_LOGFILE.empty()) Log::setLogFile(theConfig.DEBUG_LOGFILE); + mSNTPClient.init(theConfig.SNTP_SERVERS); + + boost::thread auxThread(boost::bind(&boost::asio::io_service::run, &mAuxService)); + auxThread.detach(); + // // Construct databases. // @@ -91,6 +97,7 @@ void Application::run() // getUNL().nodeBootstrap(); + // // Allow peer connections. // @@ -147,7 +154,6 @@ void Application::run() mNetOps.setLastCloseNetTime(secondLedger->getCloseTimeNC()); } - mSNTPClient.init(theConfig.SNTP_SERVERS); mNetOps.setStateTimer(); diff --git a/src/Application.h b/src/Application.h index 9efbc89fc1..79ffb8cf34 100644 --- a/src/Application.h +++ b/src/Application.h @@ -39,7 +39,7 @@ public: class Application { - boost::asio::io_service mIOService; + boost::asio::io_service mIOService, mAuxService; Wallet mWallet; UniqueNodeList mUNL; diff --git a/src/LedgerTiming.cpp b/src/LedgerTiming.cpp index c28fc80e02..0585abd47a 100644 --- a/src/LedgerTiming.cpp +++ b/src/LedgerTiming.cpp @@ -19,8 +19,8 @@ int ContinuousLedgerTiming::shouldClose( int previousMSeconds, // seconds the previous ledger took to reach consensus int currentMSeconds) // seconds since the previous ledger closed { - assert((previousMSeconds > 0) && (previousMSeconds < 600000)); - assert((currentMSeconds >= 0) && (currentMSeconds < 600000)); + assert((previousMSeconds > -1000) && (previousMSeconds < 600000)); + assert((currentMSeconds >= -1000) && (currentMSeconds < 600000)); #if 0 Log(lsTRACE) << boost::str(boost::format("CLC::shouldClose Trans=%s, Prop: %d/%d, Secs: %d (last:%d)") % @@ -44,12 +44,6 @@ int ContinuousLedgerTiming::shouldClose( return LEDGER_IDLE_INTERVAL * 1000; // normal idle } - if (previousMSeconds == (1000 * LEDGER_IDLE_INTERVAL)) // coming out of idle, close now - { - Log(lsTRACE) << "leaving idle, close now"; - return currentMSeconds; - } - Log(lsTRACE) << "close now"; return currentMSeconds; // this ledger should close now } diff --git a/src/SNTPClient.cpp b/src/SNTPClient.cpp index ffd2eecbe9..728e6f4129 100644 --- a/src/SNTPClient.cpp +++ b/src/SNTPClient.cpp @@ -166,7 +166,9 @@ void SNTPClient::processReply() if ((mOffset == -1) || (mOffset == 1)) // small corrections likely do more harm than good mOffset = 0; +#ifndef SNTP_DEBUG if (timev || mOffset) +#endif Log(lsTRACE) << "SNTP: Offset is " << timev << ", new system offset is " << mOffset; }