From f029079b6e7c715df38fc74922367d437c4e4889 Mon Sep 17 00:00:00 2001 From: Hari Date: Thu, 4 Jun 2015 18:06:36 +0530 Subject: [PATCH] Fix valgrind reported issue in HTTP client check_multi_info is invoked from "http client" and asio contexts. Calling delete of connection info from here causes problems due to this. Moving this such that if a new connection is created and if old connection info is available, it is deleted. The last one is deleted when HttpConnection is removed. Rechecked valgrind with this fix. Change-Id: I0d2592b6ddb098d8f86e8036b0c1aa5c979627ac closes-bug: 1461910 (cherry picked from commit 25d37477939bd3ea5adf2847e2ceb0f471f22bd9) --- src/http/client/http_client.cc | 4 ++++ src/http/client/http_curl.cc | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/http/client/http_client.cc b/src/http/client/http_client.cc index 5dbfca5242c..355f38e0ec1 100644 --- a/src/http/client/http_client.cc +++ b/src/http/client/http_client.cc @@ -202,6 +202,10 @@ void HttpConnection::HttpProcessInternal(const std::string body, std::string pat return; } + if (curl_handle_) { + // delete existing curl_handle + del_curl_handle(curl_handle_, gi); + } curl_handle->connection = this; set_curl_handle(curl_handle); diff --git a/src/http/client/http_curl.cc b/src/http/client/http_curl.cc index 900ae935c44..c3d8bd4ec91 100644 --- a/src/http/client/http_curl.cc +++ b/src/http/client/http_curl.cc @@ -97,9 +97,6 @@ static void check_multi_info(GlobalInfo *g) std::string empty_str(""); if (conn->connection->HttpClientCb() != NULL) conn->connection->HttpClientCb()(empty_str, error); - - conn->connection->set_curl_handle(NULL); - del_curl_handle(conn, g); } } }