Load PeerFinder database in Stoppable::onPrepare:

OverlayImpl::onStart calls into PeerFinder before PeerFinder::Manager::onStart,
causing tests to sometimes fail and the application to intermittently not start.
The order of calls to Stoppable::onStart is implementation defined and not
predictable.

This changes PeerFinder to load the database in Stoppable::onPrepare, before
threads are launched. In general, creation and initialization of resources that
are shared between classes should happen in onPrepare rather than onStart,
to solve this problem.
This commit is contained in:
Vinnie Falco
2014-10-10 19:30:00 -07:00
parent 7c0c2419f7
commit 4b5625fd59

View File

@@ -201,14 +201,9 @@ public:
//
//--------------------------------------------------------------------------
void onPrepare ()
{
}
void
onStart()
onPrepare ()
{
m_journal.debug << "Initializing";
beast::Error error (m_store.open (m_databaseFile));
if (error)
m_journal.fatal <<
@@ -217,6 +212,11 @@ public:
m_logic.load ();
}
void
onStart()
{
}
void onStop ()
{
m_journal.debug << "Stopping";