aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoin-cli.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2019-10-21 12:21:19 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-10-21 12:21:26 +0200
commit5b68d1654f078bdcc7a1a79300d5db7eb5b8f40e (patch)
tree004652ee3ab46aabeb9484efc27206c2902e1dbb /src/bitcoin-cli.cpp
parent3834d3d12196da5ac3549af195bc81d497c2b970 (diff)
parent334e27ed5aae2dbe767b73eac8876edf5ab2b797 (diff)
downloadbitcoin-5b68d1654f078bdcc7a1a79300d5db7eb5b8f40e.tar.xz
Merge #17197: [0.19.0] Backports
334e27ed5aae2dbe767b73eac8876edf5ab2b797 util: Filter out macOS process serial number (Hennadii Stepanov) e1bacb591a75375461cdf9e39e4dda4acdbd6981 rpc: fix -rpcclienttimeout 0 option (Fabian Jahr) 6a45766acbf4fc8d2ce8ab3e1eb1afc85a7c05ca doc: update bips.md with buried BIP9 deployments (MarcoFalke) dc0fe7ae1f941a2aafc29a0c7b7068e160583ef4 util: Filter control characters out of log messages (Wladimir J. van der Laan) ba46f394182dc2ac85ea7e0a7b6141312180de73 init: Change fallback locale to C.UTF-8 (Wladimir J. van der Laan) Pull request description: Backports the following PRs to the `0.19.0` [branch](https://github.com/bitcoin/bitcoin/tree/0.19): * #17184 - util: Filter out macOS process serial number * #17131 - rpc: fix -rpcclienttimeout 0 option * #17111 - doc: update bips.md with buried BIP9 deployments * #17095 - util: Filter control characters out of log messages * #17085 - init: Change fallback locale to C.UTF-8 ACKs for top commit: laanwj: ACK 334e27ed5aae2dbe767b73eac8876edf5ab2b797 Tree-SHA512: 436064c00f98bae8475d0e46ab104df6fc9bdae4927dcdd5cffa4242704256c749352e9cabb23cf806911b1c303ddcb0208a42d540412e98da2513176e5e1023
Diffstat (limited to 'src/bitcoin-cli.cpp')
-rw-r--r--src/bitcoin-cli.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp
index a6756fcce7..7fdd8e9466 100644
--- a/src/bitcoin-cli.cpp
+++ b/src/bitcoin-cli.cpp
@@ -314,7 +314,20 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
// Synchronously look up hostname
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;
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);