Skip to content

Commit

Permalink
fix(push): second PR(#598) comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jinrui committed Jun 21, 2022
1 parent 280a00f commit 5a4c3f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
10 changes: 3 additions & 7 deletions push/src/curl_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ CurlWrapper::CurlWrapper(const std::string& username,
}

CurlWrapper::~CurlWrapper() {
if (optHttpHeader_ != nullptr)
{
curl_slist_free_all(optHttpHeader_);
}
curl_slist_free_all(optHttpHeader_);
curl_easy_cleanup(curl_);
curl_global_cleanup();
}
Expand Down Expand Up @@ -111,11 +108,10 @@ int CurlWrapper::performHttpRequest(HttpMethod method, const std::string& uri,
return response_code;
}

int CurlWrapper::addOptHttpHeader(const std::string& header)
int CurlWrapper::addHttpHeader(const std::string& header)
{
std::lock_guard<std::mutex> lock{mutex_};
curl_slist* header_tmp = nullptr;
header_tmp = curl_slist_append(optHttpHeader_, header.c_str());
auto header_tmp = curl_slist_append(optHttpHeader_, header.c_str());
if (nullptr == header_tmp)
{
return -1;
Expand Down
2 changes: 1 addition & 1 deletion push/src/curl_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CurlWrapper {

int performHttpRequest(HttpMethod method, const std::string& uri,
const std::string& body);
int addOptHttpHeader(const std::string& header);
int addHttpHeader(const std::string& header);

private:
CURL* curl_;
Expand Down
3 changes: 1 addition & 2 deletions push/src/gateway.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ void Gateway::CleanupStalePointers(

int Gateway::AddHttpHeader(const std::string& header)
{
std::lock_guard<std::mutex> lock{mutex_};
return curlWrapper_->addOptHttpHeader(header);
return curlWrapper_->addHttpHeader(header);
}

} // namespace prometheus

0 comments on commit 5a4c3f6

Please sign in to comment.