Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trim__FILE__' into remote-io-pin…
Browse files Browse the repository at this point in the history
…ned-bounce-buffer
  • Loading branch information
madsbk committed Oct 28, 2024
2 parents 1e9e736 + 23dc762 commit a555d85
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpp/include/kvikio/shim/libcurl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"cannot include the remote IO API, please build KvikIO with libcurl (-DKvikIO_REMOTE_SUPPORT=ON)"
#endif

#include <algorithm>
#include <cstring>
#include <functional>
#include <memory>
Expand Down Expand Up @@ -150,7 +151,7 @@ class CurlHandle {
/**
* @brief Construct a new curl handle.
*
* Typically, do not use this directly instead use the `create_curl_handle()` macro.
* Typically, do not call this directly instead use the `create_curl_handle()` macro.
*
* @param handle An unused curl easy handle pointer, which is retained on destruction.
* @param source_file Path of source file of the caller (for error messages).
Expand All @@ -161,11 +162,16 @@ class CurlHandle {
_source_file(std::move(source_file)),
_source_line(std::move(source_line))
{
// Removing all '\0' characters
_source_file.erase(std::remove(_source_file.begin(), _source_file.end(), '\0'),
_source_file.end());

// Need CURLOPT_NOSIGNAL to support threading, see
// <https://curl.se/libcurl/c/CURLOPT_NOSIGNAL.html>
setopt(CURLOPT_NOSIGNAL, 1L);

// We always set CURLOPT_ERRORBUFFER to get better error messages.
_errbuf[0] = 0; // Set the error buffer as empty.
setopt(CURLOPT_ERRORBUFFER, _errbuf);

// Make curl_easy_perform() fail when receiving HTTP code errors.
Expand Down Expand Up @@ -216,7 +222,7 @@ class CurlHandle {
// Perform the curl operation and check for errors.
CURLcode err = curl_easy_perform(handle());
if (err != CURLE_OK) {
std::string msg(_errbuf);
std::string msg(_errbuf); // We can do this because we always initialize `_errbuf` as empty.
std::stringstream ss;
ss << "curl_easy_perform() error near " << _source_file << ":" << _source_line;
if (msg.empty()) {
Expand Down

0 comments on commit a555d85

Please sign in to comment.