aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2013-11-20 17:57:43 -0800
committerGavin Andresen <[email protected]>2013-11-20 17:57:43 -0800
commit34f5b0ab93e4f92e92531afa090caba06a031c68 (patch)
tree8ac47d1d46c08c7aa5c6759e19f41befd3f9c1d0 /src/bitcoinrpc.cpp
parentMerge pull request #3257 (diff)
parentRPC client option: -rpcwait, to wait for server start (diff)
downloaddiscoin-34f5b0ab93e4f92e92531afa090caba06a031c68.tar.xz
discoin-34f5b0ab93e4f92e92531afa090caba06a031c68.zip
Merge pull request #3283 from gavinandresen/rpcwait
RPC client option: -rpcwait, to wait for server start
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r--src/bitcoinrpc.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 9d45779b2..a1e7d14dc 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1122,8 +1122,16 @@ Object CallRPC(const string& strMethod, const Array& params)
asio::ssl::stream<asio::ip::tcp::socket> sslStream(io_service, context);
SSLIOStreamDevice<asio::ip::tcp> d(sslStream, fUseSSL);
iostreams::stream< SSLIOStreamDevice<asio::ip::tcp> > stream(d);
- if (!d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort()))))
- throw runtime_error("couldn't connect to server");
+
+ bool fWait = GetBoolArg("-rpcwait", false); // -rpcwait means try until server has started
+ do {
+ bool fConnected = d.connect(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", itostr(Params().RPCPort())));
+ if (fConnected) break;
+ if (fWait)
+ MilliSleep(1000);
+ else
+ throw runtime_error("couldn't connect to server");
+ } while (fWait);
// HTTP basic authentication
string strUserPass64 = EncodeBase64(mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"]);