Skip to content

Commit

Permalink
MiniCurl: Make it safe to reuse a MiniCurl object
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Dec 22, 2022
1 parent 804880a commit 0fe3a25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pdns/minicurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ static string extractHostFromURL(const std::string& url)

void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, size_t byteslimit, bool fastopen, bool verify)
{
if (!d_fresh) {
curl_easy_reset(getCURLPtr(d_curl));
}
else {
d_fresh = false;
}

clearHostsList();

if (rem) {
struct curl_slist *hostlist = nullptr; // THIS SHOULD BE FREED

Expand Down
1 change: 1 addition & 0 deletions pdns/minicurl.hh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private:
#endif
std::string d_data;
size_t d_byteslimit{};
bool d_fresh{true};

void setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, size_t byteslimit, bool fastopen, bool verify);
void setHeaders(const MiniCurlHeaders& headers);
Expand Down

0 comments on commit 0fe3a25

Please sign in to comment.