Merge pull request #6695
ddf98d1Make RPC tests cope with server-side timeout between requests (Wladimir J. van der Laan)2190ea6rpc: Split option -rpctimeout into -rpcservertimeout and -rpcclienttimeout (Wladimir J. van der Laan)8b2d6edhttp: Disable libevent debug logging, if not explicitly enabled (Wladimir J. van der Laan)5ce43dainit: Ignore SIGPIPE (Wladimir J. van der Laan)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -320,6 +320,15 @@ static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue)
|
||||
queue->Run();
|
||||
}
|
||||
|
||||
/** libevent event log callback */
|
||||
static void libevent_log_cb(int severity, const char *msg)
|
||||
{
|
||||
if (severity >= EVENT_LOG_WARN) // Log warn messages and higher without debug category
|
||||
LogPrintf("libevent: %s\n", msg);
|
||||
else
|
||||
LogPrint("libevent", "libevent: %s\n", msg);
|
||||
}
|
||||
|
||||
bool InitHTTPServer()
|
||||
{
|
||||
struct evhttp* http = 0;
|
||||
@@ -335,6 +344,16 @@ bool InitHTTPServer()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Redirect libevent's logging to our own log
|
||||
event_set_log_callback(&libevent_log_cb);
|
||||
#if LIBEVENT_VERSION_NUMBER >= 0x02010100
|
||||
// If -debug=libevent, set full libevent debugging.
|
||||
// Otherwise, disable all libevent debugging.
|
||||
if (LogAcceptCategory("libevent"))
|
||||
event_enable_debug_logging(EVENT_DBG_ALL);
|
||||
else
|
||||
event_enable_debug_logging(EVENT_DBG_NONE);
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
evthread_use_windows_threads();
|
||||
#else
|
||||
@@ -355,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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -416,7 +416,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));
|
||||
strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
|
||||
}
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http"; // Don't translate these and qt below
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http, libevent"; // 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) + ". " +
|
||||
@@ -469,7 +469,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)
|
||||
@@ -716,10 +716,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
sa_hup.sa_flags = 0;
|
||||
sigaction(SIGHUP, &sa_hup, NULL);
|
||||
|
||||
#if defined (__SVR4) && defined (__sun)
|
||||
// ignore SIGPIPE on Solaris
|
||||
// Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// ********************************************************* Step 2: parameter interactions
|
||||
|
||||
Reference in New Issue
Block a user