mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
rpc: fix -rpcclienttimeout 0 option
This commit is contained in:
parent
561a7d3047
commit
b3b26e149c
1 changed files with 14 additions and 1 deletions
|
@ -316,7 +316,20 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
|
||||||
|
|
||||||
// Synchronously look up hostname
|
// Synchronously look up hostname
|
||||||
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
|
raii_evhttp_connection evcon = obtain_evhttp_connection_base(base.get(), host, port);
|
||||||
evhttp_connection_set_timeout(evcon.get(), gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT));
|
|
||||||
|
// Set connection timeout
|
||||||
|
{
|
||||||
|
const int timeout = gArgs.GetArg("-rpcclienttimeout", DEFAULT_HTTP_CLIENT_TIMEOUT);
|
||||||
|
if (timeout > 0) {
|
||||||
|
evhttp_connection_set_timeout(evcon.get(), timeout);
|
||||||
|
} else {
|
||||||
|
// Indefinite request timeouts are not possible in libevent-http, so we
|
||||||
|
// set the timeout to a very long time period instead.
|
||||||
|
|
||||||
|
constexpr int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
|
||||||
|
evhttp_connection_set_timeout(evcon.get(), 5 * YEAR_IN_SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HTTPReply response;
|
HTTPReply response;
|
||||||
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
|
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
|
||||||
|
|
Loading…
Add table
Reference in a new issue