aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-09-18 15:45:38 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2015-09-21 17:15:36 +0200
commit2190ea6c4e7f56f29fc18539284801a5f504ee48 (patch)
tree8d4aa8f26c2912f6c53cca7bc34137d254dd9d67 /src
parent8b2d6edaa9fbfb6344ca51edd0b3655b451cbcac (diff)
rpc: Split option -rpctimeout into -rpcservertimeout and -rpcclienttimeout
The two timeouts for the server and client, are essentially different: - In the case of the server it should be a lower value to avoid clients clogging up connection slots - In the case of the client it should be a high value to accomedate slow responses from the server, for example for slow queries or when the lock is contended Split the options into `-rpcservertimeout` and `-rpcclienttimeout` with respective defaults of 30 and 900.
Diffstat (limited to 'src')
-rw-r--r--src/bitcoin-cli.cpp5
-rw-r--r--src/httpserver.cpp2
-rw-r--r--src/httpserver.h2
-rw-r--r--src/init.cpp2
4 files changed, 7 insertions, 4 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index 866c6f2d44..7839b3b6b4 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -22,6 +22,8 @@
using namespace std;
+static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
+
std::string HelpMessageCli()
{
string strUsage;
@@ -37,6 +39,7 @@ std::string HelpMessageCli()
strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
+ strUsage += HelpMessageOpt("-rpcclienttimeout=<n>", strprintf(_("Timeout during HTTP requests (default: %d)"), DEFAULT_HTTP_CLIENT_TIMEOUT));
return strUsage;
}
@@ -150,7 +153,7 @@ UniValue CallRPC(const string& strMethod, const UniValue& params)
struct evhttp_connection *evcon = evhttp_connection_base_new(base, NULL, host.c_str(), port); // TODO RAII
if (evcon == NULL)
throw runtime_error("create connection failed");
- evhttp_connection_set_timeout(evcon, GetArg("-rpctimeout", 30));
+ evhttp_connection_set_timeout(evcon, GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
HTTPReply response;
struct evhttp_request *req = evhttp_request_new(http_request_done, (void*)&response); // TODO RAII
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 3fc8802143..600e57b7cc 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -374,7 +374,7 @@ bool InitHTTPServer()
return false;
}
- evhttp_set_timeout(http, GetArg("-rpctimeout", DEFAULT_HTTP_TIMEOUT));
+ evhttp_set_timeout(http, GetArg("-rpcservertimeout", DEFAULT_HTTP_SERVER_TIMEOUT));
evhttp_set_max_body_size(http, MAX_SIZE);
evhttp_set_gencb(http, http_request_cb, NULL);
diff --git a/src/httpserver.h b/src/httpserver.h
index 459c60c047..b377dc19fc 100644
--- a/src/httpserver.h
+++ b/src/httpserver.h
@@ -13,7 +13,7 @@
static const int DEFAULT_HTTP_THREADS=4;
static const int DEFAULT_HTTP_WORKQUEUE=16;
-static const int DEFAULT_HTTP_TIMEOUT=30;
+static const int DEFAULT_HTTP_SERVER_TIMEOUT=30;
struct evhttp_request;
struct event_base;
diff --git a/src/init.cpp b/src/init.cpp
index c259e3fa2d..3b35fb380e 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -440,7 +440,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
if (showDebug) {
strUsage += HelpMessageOpt("-rpcworkqueue=<n>", strprintf("Set the depth of the work queue to service RPC calls (default: %d)", DEFAULT_HTTP_WORKQUEUE));
- strUsage += HelpMessageOpt("-rpctimeout=<n>", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_TIMEOUT));
+ strUsage += HelpMessageOpt("-rpcservertimeout=<n>", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
}
if (mode == HMM_BITCOIN_QT)