From 8d08172d0d0fb2b7dbeb279a91ee2c3a935fb6c5 Mon Sep 17 00:00:00 2001 From: Simon Date: Fri, 19 Aug 2016 12:25:33 -0700 Subject: [PATCH] Add config option 'rpcasyncthreads' to specify number of async rpc workers. Default is 1. --- src/init.cpp | 1 + src/rpcserver.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 788f3902..8acc13df 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -424,6 +424,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-rpcallowip=", _("Allow JSON-RPC connections from specified source. Valid for are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times")); strUsage += HelpMessageOpt("-rpcthreads=", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), 4)); strUsage += HelpMessageOpt("-rpckeepalive", strprintf(_("RPC support for HTTP persistent connections (default: %d)"), 1)); + strUsage += HelpMessageOpt("-rpcasyncthreads=", strprintf(_("Set the number of threads to service Async RPC calls (default: %d)"), 1)); strUsage += HelpMessageGroup(_("RPC SSL options: (see the Bitcoin Wiki for SSL setup instructions)")); strUsage += HelpMessageOpt("-rpcssl", _("Use OpenSSL (https) for JSON-RPC connections")); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 75f542aa..819ff4b2 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -746,9 +746,16 @@ void StartRPCThreads() // Launch at least one async rpc worker async_rpc_queue = std::make_shared(); - async_rpc_queue->addWorker(); - async_rpc_queue->addWorker(); - async_rpc_queue->addWorker(); + int n = GetArg("-rpcasyncthreads", 1); + if (n<1) { + LogPrintf("ERROR: Invalid value %d for -rpcasyncthreads. Must be at least 1.\n", n); + strerr = strprintf(_("An error occurred while setting up the Async RPC threads, invalid parameter value of %d (must be at least 1)."), n); + uiInterface.ThreadSafeMessageBox(strerr, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return; + } + for (int i = 0; i < n; i++) + async_rpc_queue->addWorker(); }