mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-24 04:55:52 +00:00
Some work towards clean shudown
This commit is contained in:
@@ -333,6 +333,7 @@ void Application::stop ()
|
|||||||
mEphemeralLDB = NULL;
|
mEphemeralLDB = NULL;
|
||||||
|
|
||||||
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped ();
|
WriteLog (lsINFO, Application) << "Stopped: " << mIOService.stopped ();
|
||||||
|
mShutdown = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitDB (DatabaseCon** dbCon, const char* fileName, const char* dbInit[], int dbCount)
|
static void InitDB (DatabaseCon** dbCon, const char* fileName, const char* dbInit[], int dbCount)
|
||||||
@@ -469,7 +470,7 @@ void Application::setup ()
|
|||||||
{
|
{
|
||||||
getApp().getHashNodeDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
getApp().getHashNodeDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||||
(theConfig.getSize (siHashNodeDBCache) * 1024)));
|
(theConfig.getSize (siHashNodeDBCache) * 1024)));
|
||||||
getApp().getHashNodeDB ()->getDB ()->setupCheckpointing (&mJobQueue);
|
getApp().getHashNodeDB ()->getDB ()->setupCheckpointing (&mJobQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
getApp().getLedgerDB ()->getDB ()->executeSQL (boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||||
@@ -665,7 +666,12 @@ void Application::run ()
|
|||||||
if (mWSPrivateDoor)
|
if (mWSPrivateDoor)
|
||||||
mWSPrivateDoor->stop ();
|
mWSPrivateDoor->stop ();
|
||||||
|
|
||||||
|
getApp().getLoadManager().stopThread();
|
||||||
|
mSweepTimer.cancel();
|
||||||
|
|
||||||
WriteLog (lsINFO, Application) << "Done.";
|
WriteLog (lsINFO, Application) << "Done.";
|
||||||
|
while (mShutdown)
|
||||||
|
boost::this_thread::sleep (boost::posix_time::milliseconds (100));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::sweep ()
|
void Application::sweep ()
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
// VFALCO TODO Simplify the two stage initialization to one stage (construction).
|
// VFALCO TODO Simplify the two stage initialization to one stage (construction).
|
||||||
virtual void startThread () = 0;
|
virtual void startThread () = 0;
|
||||||
|
virtual void stopThread () = 0;
|
||||||
|
|
||||||
/** Turn on deadlock detection.
|
/** Turn on deadlock detection.
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ public:
|
|||||||
, mDebitWarn (-500)
|
, mDebitWarn (-500)
|
||||||
, mDebitLimit (-1000)
|
, mDebitLimit (-1000)
|
||||||
, mArmed (false)
|
, mArmed (false)
|
||||||
|
, mRunning (false)
|
||||||
, mDeadLock (0)
|
, mDeadLock (0)
|
||||||
, mCosts (LT_MAX)
|
, mCosts (LT_MAX)
|
||||||
{
|
{
|
||||||
@@ -116,7 +117,11 @@ private:
|
|||||||
{
|
{
|
||||||
UptimeTimer::getInstance ().endManualUpdates ();
|
UptimeTimer::getInstance ().endManualUpdates ();
|
||||||
|
|
||||||
m_thread.interrupt ();
|
if (mRunning)
|
||||||
|
{
|
||||||
|
m_thread.interrupt ();
|
||||||
|
m_thread.join ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startThread ()
|
void startThread ()
|
||||||
@@ -124,6 +129,17 @@ private:
|
|||||||
UptimeTimer::getInstance ().beginManualUpdates ();
|
UptimeTimer::getInstance ().beginManualUpdates ();
|
||||||
|
|
||||||
m_thread.start (this);
|
m_thread.start (this);
|
||||||
|
mRunning = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stopThread()
|
||||||
|
{
|
||||||
|
if (mRunning)
|
||||||
|
{
|
||||||
|
m_thread.interrupt ();
|
||||||
|
m_thread.join ();
|
||||||
|
mRunning = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void canonicalize (LoadSource& source, int now) const
|
void canonicalize (LoadSource& source, int now) const
|
||||||
@@ -401,7 +417,7 @@ private:
|
|||||||
int mDebitWarn; // when a source drops below this, we warn
|
int mDebitWarn; // when a source drops below this, we warn
|
||||||
int mDebitLimit; // when a source drops below this, we cut it off (should be negative)
|
int mDebitLimit; // when a source drops below this, we cut it off (should be negative)
|
||||||
|
|
||||||
bool mArmed;
|
bool mArmed, mRunning;
|
||||||
|
|
||||||
int mDeadLock; // Detect server deadlocks
|
int mDeadLock; // Detect server deadlocks
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user