]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/s3website: Fix ErrocDoc memory leak.
authorRobin H. Johnson <robin.johnson@dreamhost.com>
Wed, 18 May 2016 00:35:41 +0000 (17:35 -0700)
committerRobin H. Johnson <robin.johnson@dreamhost.com>
Tue, 7 Jun 2016 20:28:44 +0000 (13:28 -0700)
Yehuda pointed [1] out a memory leak with the RGWGetObj not being handed back, and
suggested that shared_ptr was used to handle it, rather than the prior approach
of explicitly calling handler->put_op.

This commit implements just that change, in isolation from other changes, for
ease of comparision testing.

X-Reference-1: https://github.com/ceph/ceph/pull/8669#discussion_r63445516
Signed-off-by: Robin H. Johnson <robin.johnson@dreamhost.com>
(cherry picked from commit 2fd7bc8cbe4a2e23553e716ce0be75937853e07b)

src/rgw/rgw_rest_s3.cc

index 518ad2ba1a2906a1851f44f0d64ea446efafcbf4..b70f11ddaf105d0d87066a39628281cdc490fc51 100644 (file)
@@ -3973,8 +3973,8 @@ int RGWHandler_REST_S3Website::serve_errordoc(int http_ret, const string& errord
   int ret = 0;
   s->formatter->reset(); /* Try to throw it all away */
 
-  RGWGetObj_ObjStore_S3Website* getop = (RGWGetObj_ObjStore_S3Website*) op_get();
-  if(!getop) {
+  std::shared_ptr<RGWGetObj_ObjStore_S3Website> getop( (RGWGetObj_ObjStore_S3Website*) op_get() );
+  if (getop.get() == NULL) {
     return -1; // Trigger double error handler
   }
   getop->init(store, s, this);
@@ -3985,13 +3985,13 @@ int RGWHandler_REST_S3Website::serve_errordoc(int http_ret, const string& errord
   getop->if_nomatch = NULL;
   s->object = errordoc_key;
 
-  ret = init_permissions(getop);
+  ret = init_permissions(getop.get());
   if (ret < 0) {
     ldout(s->cct, 20) << "serve_errordoc failed, init_permissions ret=" << ret << dendl;
     return -1; // Trigger double error handler
   }
 
-  ret = read_permissions(getop);
+  ret = read_permissions(getop.get());
   if (ret < 0) {
     ldout(s->cct, 20) << "serve_errordoc failed, read_permissions ret=" << ret << dendl;
     return -1; // Trigger double error handler