diff --git a/README.md b/README.md index eca1a70d39..e4db25d15a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Requirements to build: - newer versions do not work - openssl 1.1+ - curl +- libcurl 7.40.0+ - git - GMP - Python 3 @@ -70,7 +71,7 @@ git clone --recursive https://github.com/AntelopeIO/leap.git git clone --recursive git@github.com:AntelopeIO/leap.git ``` -> ℹ️ **HTTPS vs. SSH Clone** ℹ️ +> ℹ️ **HTTPS vs. SSH Clone** ℹ️ Both an HTTPS or SSH git clone will yield the same result - a folder named `leap` containing our source code. It doesn't matter which type you use. Navigate into that folder: @@ -94,13 +95,13 @@ git submodule update --init --recursive ### Step 3 - Build Select build instructions below for a [pinned build](#pinned-build) (preferred) or an [unpinned build](#unpinned-build). -> ℹ️ **Pinned vs. Unpinned Build** ℹ️ +> ℹ️ **Pinned vs. Unpinned Build** ℹ️ We have two types of builds for Leap: "pinned" and "unpinned." The only difference is that pinned builds use specific versions for some dependencies hand-picked by the Leap engineers - they are "pinned" to those versions. In contrast, unpinned builds use the default dependency versions available on the build system at the time. We recommend performing a "pinned" build to ensure the compiler and boost versions remain the same between builds of different Leap versions. Leap requires these versions to remain the same, otherwise its state might need to be recovered from a portable snapshot or the chain needs to be replayed. -> ⚠️ **A Warning On Parallel Compilation Jobs (`-j` flag)** ⚠️ +> ⚠️ **A Warning On Parallel Compilation Jobs (`-j` flag)** ⚠️ When building C/C++ software, often the build is performed in parallel via a command such as `make -j "$(nproc)"` which uses all available CPU threads. However, be aware that some compilation units (`*.cpp` files) in Leap will consume nearly 4GB of memory. Failures due to memory exhaustion will typically, but not always, manifest as compiler crashes. Using all available CPU threads may also prevent you from doing other things on your computer during compilation. For these reasons, consider reducing this value. -> 🐋 **Docker and `sudo`** 🐋 +> 🐋 **Docker and `sudo`** 🐋 If you are in an Ubuntu docker container, omit `sudo` from all commands because you run as `root` by default. Most other docker containers also exclude `sudo`, especially Debian-family containers. If your shell prompt is a hash tag (`#`), omit `sudo`. #### Pinned Build diff --git a/programs/cleos/do_http_post_libcurl.cpp b/programs/cleos/do_http_post_libcurl.cpp index 212109c221..ca47d5dd91 100644 --- a/programs/cleos/do_http_post_libcurl.cpp +++ b/programs/cleos/do_http_post_libcurl.cpp @@ -3,7 +3,7 @@ #include "do_http_post.hpp" #include #include -#include +#include namespace eosio { namespace client { namespace http { @@ -65,6 +65,11 @@ namespace eosio { namespace client { namespace http { return 0; } + struct curl_handle : std::unique_ptr { + curl_handle(int) : std::unique_ptr( curl_easy_init(), &curl_easy_cleanup) {} + }; + + std::tuple do_http_post(const std::string& base_uri, const std::string& path, const std::vector& headers, const std::string& postjson, bool verify_cert, bool verbose, @@ -78,11 +83,10 @@ namespace eosio { namespace client { namespace http { initialized = true; } - auto curl = curl_easy_init(); + static std::map handles; + auto [itr, _] = handles.emplace(base_uri, 0); + auto curl = itr->second.get(); EOS_ASSERT(curl != 0, chain::http_exception, "curl_easy_init failed"); - auto on_exit = fc::make_scoped_exit([curl]() { - curl_easy_cleanup(curl); - }); std::string uri;