mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
Merge pull request #5677
d528025Revert "rpc-tests: re-enable rpc-tests for Windows" (Wladimir J. van der Laan)1e700c9doc: update deps in build-unix.md after libevent (Wladimir J. van der Laan)26c9b83Move windows socket init to utility function (Wladimir J. van der Laan)4be0b08libevent: Windows reuseaddr workaround in depends (Cory Fields)3a174cdFix race condition between starting HTTP server thread and setting EventBase() (Wladimir J. van der Laan) 6d2bc22 Document options for new HTTP/RPC server in --help (Wladimir J. van der Laan)be33f3fImplement RPCTimerHandler for Qt RPC console (Wladimir J. van der Laan)57d85d9doc: mention SSL support dropped for RPC in release notes (Wladimir J. van der Laan)40b556devhttpd implementation (Wladimir J. van der Laan)ee2a42btests: GET requests cannot have request body, use POST in rest.py (Wladimir J. van der Laan)6e996d3tests: fix qt payment test (Cory Fields)3140ef9build: build-system changes for libevent (Wladimir J. van der Laan)a9af234libevent: add depends (Cory Fields)6a21dd5Remove rpc_boostasiotocnetaddr test (Wladimir J. van der Laan)8f9301cqa: Remove -rpckeepalive tests from httpbasics (Wladimir J. van der Laan)51fcfc0doc: remove documentation for rpcssl (Wladimir J. van der Laan)
This commit is contained in:
67
src/init.cpp
67
src/init.cpp
@@ -16,6 +16,8 @@
|
||||
#include "checkpoints.h"
|
||||
#include "compat/sanity.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "httpserver.h"
|
||||
#include "httprpc.h"
|
||||
#include "key.h"
|
||||
#include "main.h"
|
||||
#include "miner.h"
|
||||
@@ -144,6 +146,15 @@ public:
|
||||
static CCoinsViewDB *pcoinsdbview = NULL;
|
||||
static CCoinsViewErrorCatcher *pcoinscatcher = NULL;
|
||||
|
||||
void Interrupt(boost::thread_group& threadGroup)
|
||||
{
|
||||
InterruptHTTPServer();
|
||||
InterruptHTTPRPC();
|
||||
InterruptRPC();
|
||||
InterruptREST();
|
||||
threadGroup.interrupt_all();
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
LogPrintf("%s: In progress...\n", __func__);
|
||||
@@ -158,7 +169,11 @@ void Shutdown()
|
||||
/// module was initialized.
|
||||
RenameThread("bitcoin-shutoff");
|
||||
mempool.AddTransactionsUpdated(1);
|
||||
StopRPCThreads();
|
||||
|
||||
StopHTTPRPC();
|
||||
StopREST();
|
||||
StopRPC();
|
||||
StopHTTPServer();
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain)
|
||||
pwalletMain->Flush(false);
|
||||
@@ -372,7 +387,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", 1));
|
||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
||||
}
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune"; // Don't translate these and qt below
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http"; // Don't translate these and qt below
|
||||
if (mode == HMM_BITCOIN_QT)
|
||||
debugCategories += ", qt";
|
||||
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
||||
@@ -422,14 +437,11 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), 8332, 18332));
|
||||
strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> 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=<n>", 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 += HelpMessageGroup(_("RPC SSL options: (see the Bitcoin Wiki for SSL setup instructions)"));
|
||||
strUsage += HelpMessageOpt("-rpcssl", _("Use OpenSSL (https) for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcsslcertificatechainfile=<file.cert>", strprintf(_("Server certificate file (default: %s)"), "server.cert"));
|
||||
strUsage += HelpMessageOpt("-rpcsslprivatekeyfile=<file.pem>", strprintf(_("Server private key (default: %s)"), "server.pem"));
|
||||
strUsage += HelpMessageOpt("-rpcsslciphers=<ciphers>", strprintf(_("Acceptable ciphers (default: %s)"), "TLSv1.2+HIGH:TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!3DES:@STRENGTH"));
|
||||
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));
|
||||
}
|
||||
|
||||
if (mode == HMM_BITCOIN_QT)
|
||||
{
|
||||
@@ -601,6 +613,23 @@ bool InitSanityCheck(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppInitServers(boost::thread_group& threadGroup)
|
||||
{
|
||||
RPCServer::OnStopped(&OnRPCStopped);
|
||||
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
||||
if (!InitHTTPServer())
|
||||
return false;
|
||||
if (!StartRPC())
|
||||
return false;
|
||||
if (!StartHTTPRPC())
|
||||
return false;
|
||||
if (GetBoolArg("-rest", false) && !StartREST())
|
||||
return false;
|
||||
if (!StartHTTPServer(threadGroup))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Initialize bitcoin.
|
||||
* @pre Parameters should be parsed and config file should be read.
|
||||
*/
|
||||
@@ -628,17 +657,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
|
||||
PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy");
|
||||
if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE);
|
||||
|
||||
// Initialize Windows Sockets
|
||||
WSADATA wsadata;
|
||||
int ret = WSAStartup(MAKEWORD(2,2), &wsadata);
|
||||
if (ret != NO_ERROR || LOBYTE(wsadata.wVersion ) != 2 || HIBYTE(wsadata.wVersion) != 2)
|
||||
{
|
||||
return InitError(strprintf("Error: Winsock library failed to start (WSAStartup returned error %d)", ret));
|
||||
}
|
||||
#endif
|
||||
#ifndef WIN32
|
||||
|
||||
if (!SetupNetworking())
|
||||
return InitError("Error: Initializing networking failed");
|
||||
|
||||
#ifndef WIN32
|
||||
if (GetBoolArg("-sysperms", false)) {
|
||||
#ifdef ENABLE_WALLET
|
||||
if (!GetBoolArg("-disablewallet", false))
|
||||
@@ -961,9 +985,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (fServer)
|
||||
{
|
||||
uiInterface.InitMessage.connect(SetRPCWarmupStatus);
|
||||
RPCServer::OnStopped(&OnRPCStopped);
|
||||
RPCServer::OnPreCommand(&OnRPCPreCommand);
|
||||
StartRPCThreads();
|
||||
if (!AppInitServers(threadGroup))
|
||||
return InitError(_("Unable to start HTTP server. See debug log for details."));
|
||||
}
|
||||
|
||||
int64_t nStart;
|
||||
|
||||
Reference in New Issue
Block a user