Ugly workaround for Boost I/O service weirdness. I/O service unconditionally

terminates if it has no work to do and cannot be used to wait around for
'post' calls.
This commit is contained in:
JoelKatz
2012-09-18 12:23:14 -07:00
parent aa8ee3a165
commit d28bb9f771
2 changed files with 12 additions and 2 deletions

View File

@@ -35,8 +35,14 @@ DatabaseCon::~DatabaseCon()
delete mDatabase;
}
static void resetTimer(boost::asio::deadline_timer* timer)
{ // ugly workaround for Boost IO service weirdness
timer->expires_from_now(boost::posix_time::hours(24));
timer->async_wait(boost::bind(resetTimer, timer));
}
Application::Application() :
mUNL(mIOService),
mIOTimer(mIOService), mAuxTimer(mAuxService), mUNL(mIOService),
mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300),
mSNTPClient(mAuxService), mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
mHashNodeDB(NULL), mNetNodeDB(NULL),
@@ -44,6 +50,9 @@ Application::Application() :
{
RAND_bytes(mNonce256.begin(), mNonce256.size());
RAND_bytes(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
resetTimer(&mIOTimer);
resetTimer(&mAuxTimer);
}
extern const char *RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[];