Serialize Application start up:

These changes ensure the caller can block until the
Application object can be fully prepared (especially
listening sockets). Solves the problem where tests
can attempt connections before the server sockets are
ready.

* WebSocket blocks until listening
* Application setup blocks until prepared and started
This commit is contained in:
Vinnie Falco
2016-01-19 16:30:35 -05:00
committed by Nik Bougalis
parent 07c4262392
commit 77c0236cae
6 changed files with 56 additions and 22 deletions

View File

@@ -506,6 +506,7 @@ public:
//--------------------------------------------------------------------------
void setup() override;
void doStart() override;
void run() override;
bool isShutdown() override;
void signalStop() override;
@@ -1095,17 +1096,15 @@ void ApplicationImp::setup()
}
void
ApplicationImp::run()
ApplicationImp::doStart()
{
// VFALCO NOTE I put this here in the hopes that when unit tests run (which
// tragically require an Application object to exist or else they
// crash), the run() function will not get called and we will
// avoid doing silly things like contacting the SNTP server, or
// running the various logic threads like Validators, PeerFinder, etc.
prepare ();
start ();
}
void
ApplicationImp::run()
{
{
if (!config_->RUN_STANDALONE)
{