]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: more leaks fixes
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 29 Apr 2016 00:03:21 +0000 (17:03 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 9 May 2016 21:36:39 +0000 (14:36 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_http_client.cc
src/rgw/rgw_http_client.h
src/rgw/rgw_rest_conn.cc
src/rgw/rgw_rest_conn.h

index dd199ee2fa4aa488c5c738aba26d290d20af72bf..56540d95ea0f764e6ad53d4925092e0adceb5150 100644 (file)
@@ -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();
index f8763f8315d861b150def4696c9cd482483b664a..c31af9fa7da33d254511e1d3d6ea3c79743f4888 100644 (file)
@@ -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<string, string>(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;
index a4ea92f376271459787481a2d6c8bd8bb3b04645..ead41394f47a33cee9425d44c2de0f8e89f51831 100644 (file)
@@ -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;
   }
index 92332d3fe4869bf7ba2589abf3a4286b7f759a23..26229958dc89cc9f322367100f6ebe5623ddc612 100644 (file)
@@ -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 <class T>
 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 <class T>
 int RGWRESTPostResource::wait(T *dest)
 {
   int ret = req.wait();
-  put();
   if (ret < 0) {
     return ret;
   }