12#include "azure/core/dll_import_export.hpp"
19#include <condition_variable>
24#include <unordered_map>
26#if defined(_azure_TESTING_BUILD)
28namespace Azure {
namespace Core {
namespace Test {
29 class CurlConnectionPool_connectionPoolTest_Test;
30 class CurlConnectionPool_uniquePort_Test;
31 class CurlConnectionPool_connectionClose_Test;
32 class SdkWithLibcurl_globalCleanUp_Test;
36namespace Azure {
namespace Core {
namespace Http {
namespace _detail {
45 class CurlConnectionPool final {
46#if defined(_azure_TESTING_BUILD)
48 friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
49 friend class Azure::Core::Test::CurlConnectionPool_uniquePort_Test;
50 friend class Azure::Core::Test::CurlConnectionPool_connectionClose_Test;
51 friend class Azure::Core::Test::SdkWithLibcurl_globalCleanUp_Test;
57 using namespace Azure::Core::Http::_detail;
58 if (m_cleanThread.joinable())
61 std::unique_lock<std::mutex> lock(ConnectionPoolMutex);
63 g_curlConnectionPool.ConnectionPoolIndex.clear();
66 ConditionalVariableForCleanThread.notify_one();
70 curl_global_cleanup();
85 std::unique_ptr<CurlNetworkConnection> ExtractOrCreateCurlConnection(
88 bool resetPool =
false);
97 void MoveConnectionBackToPool(
98 std::unique_ptr<CurlNetworkConnection> connection,
109 std::unordered_map<std::string, std::list<std::unique_ptr<CurlNetworkConnection>>>
112 std::mutex ConnectionPoolMutex;
116 std::condition_variable ConditionalVariableForCleanThread;
118 AZ_CORE_DLLEXPORT
static Azure::Core::Http::_detail::CurlConnectionPool g_curlConnectionPool;
120 bool IsCleanThreadRunning =
false;
124 CurlConnectionPool() { curl_global_init(CURL_GLOBAL_ALL); }
128 size_t ConnectionsOnPool(std::string
const& host) {
return ConnectionPoolIndex[host].size(); }
130 std::thread m_cleanThread;
A request message from a client to a server.
Definition http.hpp:183
The libcurl connection keeps the curl handle and performs the data transfer to the network.
Azure::Core::Http::HttpTransport implementation via CURL.
HTTP request and response functionality.
Compute the hash value for the input binary data, using SHA256, SHA384 and SHA512.
Definition azure_assert.hpp:57
Set the libcurl connection options like a proxy and CA path.
Definition curl_transport.hpp:78