From 14176f00f44d51b7ecbf9952a1fbbe056f7988eb Mon Sep 17 00:00:00 2001 From: licc Date: Tue, 7 Feb 2023 08:31:44 +0100 Subject: [PATCH] rgw:log_list_init() catches IoCtx::nobjects_begin() exceptions Signed-off-by: lichaochao --- src/rgw/driver/rados/rgw_rados.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 4edcd4817db..067ea9ca6e9 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -1422,10 +1422,21 @@ int RGWRados::log_list_init(const DoutPrefixProvider *dpp, const string& prefix, delete state; return r; } - state->prefix = prefix; - state->obit = state->io_ctx.nobjects_begin(); - *handle = (RGWAccessHandle)state; - return 0; + try { + state->prefix = prefix; + state->obit = state->io_ctx.nobjects_begin(); + *handle = (RGWAccessHandle)state; + 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 RGWRados::log_list_next(RGWAccessHandle handle, string *name) -- 2.39.5