Skip to content

Commit

Permalink
TEMPORARY: fix at the sync HTTP client to reduce the memory pressure
Browse files Browse the repository at this point in the history
  • Loading branch information
iagaponenko committed Jan 18, 2024
1 parent e4df38d commit 62a4a99
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/http/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ void Client::read(CallbackType const& onDataRead) {
assert(onDataRead != nullptr); // no callback function provided
string const context = "Client::" + string(__func__) + " ";
_onDataRead = onDataRead;
#if 0
_errorChecked("curl_easy_setopt(CURLOPT_HTTP_VERSION)",
curl_easy_setopt(_hcurl, CURLOPT_HTTP_VERSION, (long)CURL_HTTP_VERSION_1_1));
#if 0
_errorChecked("curl_easy_setopt(CURLOPT_FORBID_REUSE)",
curl_easy_setopt(_hcurl, CURLOPT_FORBID_REUSE, 1L));
#endif
_errorChecked("curl_easy_setopt(CURLOPT_SOCKOPTFUNCTION)",
curl_easy_setopt(_hcurl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback));

#if 1
// NOTE: This option invalidates the alternative.
_errorChecked("curl_easy_setopt(CURLOPT_FORBID_REUSE)",
curl_easy_setopt(_hcurl, CURLOPT_FORBID_REUSE, 1L));
#else
long const maxCachedConnections = 512;
_errorChecked("curl_easy_setopt(CURLOPT_MAXCONNECTS)",
curl_easy_setopt(_hcurl, CURLOPT_MAXCONNECTS, maxCachedConnections));
Expand All @@ -115,6 +117,7 @@ void Client::read(CallbackType const& onDataRead) {
curl_easy_setopt(_hcurl, CURLOPT_TCP_KEEPIDLE, 3L));
_errorChecked("curl_easy_setopt(CURLOPT_TCP_KEEPINTVL)",
curl_easy_setopt(_hcurl, CURLOPT_TCP_KEEPINTVL, 3L));
#endif
#if 0
// DISABLED: the large buffer size may consume too much kernel memory(?)
// CURL_MAX_READ_SIZE is 10 MB since version 7.88.0.
Expand Down

0 comments on commit 62a4a99

Please sign in to comment.