]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: list_buckets_* catches NObjectIterator exceptions 25289/head
authorCasey Bodley <cbodley@redhat.com>
Tue, 13 Nov 2018 21:51:25 +0000 (16:51 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 27 Nov 2018 18:22:06 +0000 (13:22 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 29fcd5386940b20b21b08f217fb2abb57d7e7b32)

src/rgw/rgw_rados.cc

index 7c1fbb17e2c704ac37f3d02ac58242004b7cdd49..45efa03213d4d92160ba4867aee4273cd2720c7f 100644 (file)
@@ -4920,9 +4920,21 @@ int RGWRados::open_bucket_index_ctx(const RGWBucketInfo& bucket_info, librados::
  */
 int RGWRados::list_buckets_init(RGWAccessHandle *handle)
 {
-  librados::NObjectIterator *state = new librados::NObjectIterator(root_pool_ctx.nobjects_begin());
-  *handle = (RGWAccessHandle)state;
-  return 0;
+  try {
+    auto iter = root_pool_ctx.nobjects_begin();
+    librados::NObjectIterator *state = new librados::NObjectIterator(iter);
+    *handle = (RGWAccessHandle)state;
+    return 0;
+  } catch (const std::system_error& e) {
+    int r = -e.code().value();
+    ldout(cct, 10) << "nobjects_begin threw " << e.what()
+       << ", returning " << r << dendl;
+    return r;
+  } catch (const std::exception& e) {
+    ldout(cct, 10) << "nobjects_begin threw " << e.what()
+       << ", returning -5" << dendl;
+    return -EIO;
+  }
 }
 
 /** 
@@ -4945,8 +4957,18 @@ int RGWRados::list_buckets_next(rgw_bucket_dir_entry& obj, RGWAccessHandle *hand
     if (obj.key.name[0] == '_') {
       obj.key.name = obj.key.name.substr(1);
     }
-
-    (*state)++;
+    try {
+      (*state)++;
+    } catch (const std::system_error& e) {
+      int r = -e.code().value();
+      ldout(cct, 10) << "nobjects_begin threw " << e.what()
+         << ", returning " << r << dendl;
+      return r;
+    } catch (const std::exception& e) {
+      ldout(cct, 10) << "nobjects_begin threw " << e.what()
+         << ", returning -5" << dendl;
+      return -EIO;
+    }
   } while (obj.key.name[0] == '.'); /* skip all entries starting with '.' */
 
   return 0;