From cb797d4fd754b4a33eb34c249da3aabc65a7aba3 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 28 Apr 2016 17:03:21 -0700 Subject: [PATCH] rgw: more leaks fixes Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_http_client.cc | 10 ++++++++-- src/rgw/rgw_http_client.h | 14 +++++++++++--- src/rgw/rgw_rest_conn.cc | 4 ---- src/rgw/rgw_rest_conn.h | 4 ---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index dd199ee2fa4aa..56540d95ea0f7 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 f8763f8315d86..c31af9fa7da33 100644 --- a/src/rgw/rgw_http_client.h +++ b/src/rgw/rgw_http_client.h @@ -32,6 +32,8 @@ class RGWHTTPClient string last_url; bool verify_ssl; // Do not validate self signed certificates, default to false + atomic_t stopped; + protected: CephContext *cct; @@ -65,9 +67,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 a4ea92f376271..ead41394f47a3 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 92332d3fe4869..26229958dc89c 100644 --- a/src/rgw/rgw_rest_conn.h +++ b/src/rgw/rgw_rest_conn.h @@ -189,7 +189,6 @@ public: int wait_bl(bufferlist *pbl) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -242,7 +241,6 @@ template int RGWRESTReadResource::wait(T *dest) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -305,7 +303,6 @@ public: int wait_bl(bufferlist *pbl) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } @@ -339,7 +336,6 @@ template int RGWRESTPostResource::wait(T *dest) { int ret = req.wait(); - put(); if (ret < 0) { return ret; } -- 2.39.5