From 376f214a70a4c8bd974edc998131f9c8d6e0c34b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 9 Jan 2013 23:55:39 -0800 Subject: [PATCH] Make it easier to insert code between when the server is setup and when it's started. --- src/cpp/ripple/Application.cpp | 5 ++++- src/cpp/ripple/Application.h | 1 + src/cpp/ripple/main.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp index 8ec614bc6..b3c9c12b7 100644 --- a/src/cpp/ripple/Application.cpp +++ b/src/cpp/ripple/Application.cpp @@ -81,7 +81,7 @@ void sigIntHandler(int) } #endif -void Application::run() +void Application::setup() { #ifndef WIN32 #ifdef SIGINT @@ -256,7 +256,10 @@ void Application::run() } else mNetOps.setStateTimer(); +} +void Application::run() +{ mIOService.run(); // This blocks if (mWSPublicDoor) diff --git a/src/cpp/ripple/Application.h b/src/cpp/ripple/Application.h index ca1561379..ed950f22e 100644 --- a/src/cpp/ripple/Application.h +++ b/src/cpp/ripple/Application.h @@ -133,6 +133,7 @@ public: uint256 getNonce256() { return mNonce256; } std::size_t getNonceST() { return mNonceST; } + void setup(); void run(); void stop(); void sweep(); diff --git a/src/cpp/ripple/main.cpp b/src/cpp/ripple/main.cpp index 0373dccad..ebcef7eb0 100644 --- a/src/cpp/ripple/main.cpp +++ b/src/cpp/ripple/main.cpp @@ -17,9 +17,14 @@ extern bool AddSystemEntropy(); using namespace std; using namespace boost::unit_test; -void startServer() +void setupServer() { theApp = new Application(); + theApp->setup(); +} + +void startServer() +{ theApp->run(); // Blocks till we get a stop RPC. } @@ -194,6 +199,7 @@ int main(int argc, char* argv[]) else if (!vm.count("parameters")) { // No arguments. Run server. + setupServer(); startServer(); } else