Browse Source
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.
metaverse
Wladimir J. van der Laan
9 years ago
committed by
Jack Grigg
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
5 changed files with
8 additions and
5 deletions
contrib/debian/examples/zcash.conf
src/bitcoin-cli.cpp
src/httpserver.cpp
src/httpserver.h
src/init.cpp
@ -73,7 +73,7 @@
# How many seconds zcash will wait for a complete RPC HTTP request.
# after the HTTP connection is established.
#rpctimeout=30
#rpcclient timeout=30
# By default, only RPC connections from localhost are allowed.
# Specify as many rpcallowip= settings as you like to allow connections from other hosts,
@ -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 ;
}
@ -152,7 +155,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 ( " -rpcclient timeout " , DEFAULT_HTTP_CLIENT_TIMEOUT ) ) ;
HTTPReply response ;
struct evhttp_request * req = evhttp_request_new ( http_request_done , ( void * ) & response ) ; // TODO RAII
@ -374,7 +374,7 @@ bool InitHTTPServer()
return false ;
}
evhttp_set_timeout ( http , GetArg ( " -rpctimeout " , DEFAULT_HTTP_TIMEOUT ) ) ;
evhttp_set_timeout ( http , GetArg ( " -rpcserver timeout " , DEFAULT_HTTP_SERVER _TIMEOUT ) ) ;
evhttp_set_max_body_size ( http , MAX_SIZE ) ;
evhttp_set_gencb ( http , http_request_cb , NULL ) ;
@ -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 ;
@ -484,7 +484,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 ( " -rpcserver timeout=<n> " , strprintf ( " Timeout during HTTP requests (default: %d) " , DEFAULT_HTTP_SERVER _TIMEOUT ) ) ;
}
// Disabled until we can lock notes and also tune performance of libsnark which by default uses multiple threads