From 63c7d2a44b421cb95bb62ec3db9b2ff84e72d059 Mon Sep 17 00:00:00 2001 From: licc Date: Tue, 7 Feb 2023 09:02:19 +0100 Subject: [PATCH] rgw: RGWSI_RADOS::Pool::List::init() catches IoCtx::nobjects_begin() exceptions Signed-off-by: lichaochao --- src/rgw/services/svc_rados.cc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 7d1239cec2c..99f400f42b0 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -330,11 +330,21 @@ int RGWSI_RADOS::Pool::List::init(const DoutPrefixProvider *dpp, const string& m return -EINVAL; } - ctx.iter = ctx.ioctx.nobjects_begin(oc); - ctx.filter = filter; - ctx.initialized = true; - - return 0; + try { + ctx.iter = ctx.ioctx.nobjects_begin(oc); + ctx.filter = filter; + ctx.initialized = true; + return 0; + } catch (const std::system_error& e) { + r = -e.code().value(); + ldpp_dout(dpp, 10) << "nobjects_begin threw " << e.what() + << ", returning " << r << dendl; + return r; + } catch (const std::exception& e) { + ldpp_dout(dpp, 10) << "nobjects_begin threw " << e.what() + << ", returning -5" << dendl; + return -EIO; + } } int RGWSI_RADOS::Pool::List::get_next(const DoutPrefixProvider *dpp,