diff --git a/push/src/curl_wrapper.cc b/push/src/curl_wrapper.cc index 012b4bc8..3badcf9a 100644 --- a/push/src/curl_wrapper.cc +++ b/push/src/curl_wrapper.cc @@ -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(); } @@ -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 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; diff --git a/push/src/curl_wrapper.h b/push/src/curl_wrapper.h index c7f4ea26..f1a55afc 100644 --- a/push/src/curl_wrapper.h +++ b/push/src/curl_wrapper.h @@ -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_; diff --git a/push/src/gateway.cc b/push/src/gateway.cc index fd2540ef..7fdc099b 100644 --- a/push/src/gateway.cc +++ b/push/src/gateway.cc @@ -166,8 +166,7 @@ void Gateway::CleanupStalePointers( int Gateway::AddHttpHeader(const std::string& header) { - std::lock_guard lock{mutex_}; - return curlWrapper_->addOptHttpHeader(header); + return curlWrapper_->addHttpHeader(header); } } // namespace prometheus