]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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 23:02:47 +0000 (16:02 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit cb797d4fd754b4a33eb34c249da3aabc65a7aba3)

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 b15ab666b6a350dc511e6eb768de90793e08b406..25bf1dda8a845edd525f2c920164e12f8b45dcad 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 d2105cbf25937bf6c20dc12e989f946599e09b71..b0f9e310ccce76262a30a4a81408c3873d3a903c 100644 (file)
@@ -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<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 88bfbc6184919eb3697ad7309831ba09b861da25..64c07d2f3854d5be9ec67ad4de99a8d1ce502bd7 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 ef33b1f05dffa40c643fc845c7d9fdc076e730f5..415622f07d20955da2df6ed2616b4498546170c1 100644 (file)
@@ -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 <class T>
 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 <class T>
 int RGWRESTPostResource::wait(T *dest)
 {
   int ret = req.wait();
-  put();
   if (ret < 0) {
     return ret;
   }