From: Yehuda Sadeh Date: Fri, 29 Apr 2016 00:03:21 +0000 (-0700) Subject: rgw: more leaks fixes X-Git-Tag: v10.2.1~39^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b86332ca3ee35eb522cbf88408b7fd5f3070772;p=ceph.git rgw: more leaks fixes Signed-off-by: Yehuda Sadeh (cherry picked from commit cb797d4fd754b4a33eb34c249da3aabc65a7aba3) --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index b15ab666b6a..25bf1dda8a8 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -158,8 +158,6 @@ struct rgw_http_req_data : public RefCountedObject { void finish(int r) { Mutex::Locker l(lock); ret = r; - cond.Signal(); - done.set(1); if (easy_handle) curl_easy_cleanup(easy_handle); @@ -168,6 +166,8 @@ struct rgw_http_req_data : public RefCountedObject { easy_handle = NULL; h = NULL; + done.set(1); + cond.Signal(); } bool is_done() { @@ -252,6 +252,7 @@ int RGWHTTPClient::wait() RGWHTTPClient::~RGWHTTPClient() { if (req_data) { + wait(); req_data->put(); } } @@ -454,6 +455,7 @@ int RGWHTTPManager::add_request(RGWHTTPClient *client, const char *method, const int ret = client->init_request(method, url, req_data); if (ret < 0) { req_data->put(); + req_data = NULL; return ret; } @@ -464,6 +466,10 @@ int RGWHTTPManager::add_request(RGWHTTPClient *client, const char *method, const if (!is_threaded) { ret = link_request(req_data); + if (ret < 0) { + req_data->put(); + req_data = NULL; + } return ret; } ret = signal_thread(); diff --git a/src/rgw/rgw_http_client.h b/src/rgw/rgw_http_client.h index d2105cbf259..b0f9e310ccc 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -29,6 +29,8 @@ class RGWHTTPClient string last_url; bool verify_ssl; // Do not validate self signed certificates, default to false + atomic_t stopped; + protected: CephContext *cct; @@ -62,9 +64,15 @@ public: headers.push_back(pair(name, val)); } - virtual int receive_header(void *ptr, size_t len) = 0; - virtual int receive_data(void *ptr, size_t len) = 0; - virtual int send_data(void *ptr, size_t len) = 0; + virtual int receive_header(void *ptr, size_t len) { + return 0; + } + virtual int receive_data(void *ptr, size_t len) { + return 0; + } + virtual int send_data(void *ptr, size_t len) { + return 0; + } void set_send_length(size_t len) { send_len = len; diff --git a/src/rgw/rgw_rest_conn.cc b/src/rgw/rgw_rest_conn.cc index 88bfbc61849..64c07d2f385 100644 --- a/src/rgw/rgw_rest_conn.cc +++ b/src/rgw/rgw_rest_conn.cc @@ -262,10 +262,8 @@ int RGWRESTReadResource::read() int RGWRESTReadResource::aio_read() { - get(); int ret = req.get_resource(conn->get_key(), headers, resource, mgr); if (ret < 0) { - put(); ldout(cct, 5) << __func__ << ": get_resource() resource=" << resource << " returned ret=" << ret << dendl; return ret; } @@ -324,10 +322,8 @@ int RGWRESTPostResource::send(bufferlist& outbl) int RGWRESTPostResource::aio_send(bufferlist& outbl) { req.set_outbl(outbl); - get(); int ret = req.get_resource(conn->get_key(), headers, resource, mgr); if (ret < 0) { - put(); ldout(cct, 5) << __func__ << ": get_resource() resource=" << resource << " returned ret=" << ret << dendl; return ret; } diff --git a/src/rgw/rgw_rest_conn.h b/src/rgw/rgw_rest_conn.h index ef33b1f05df..415622f07d2 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -193,7 +193,6 @@ public: int wait_bl(bufferlist *pbl) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -246,7 +245,6 @@ template int RGWRESTReadResource::wait(T *dest) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -309,7 +307,6 @@ public: int wait_bl(bufferlist *pbl) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -343,7 +340,6 @@ template int RGWRESTPostResource::wait(T *dest) { int ret = req.wait(); - put(); if (ret < 0) { return ret; }