From: Casey Bodley Date: Wed, 8 Jun 2016 13:37:26 +0000 (-0400) Subject: rgw: add empty_on_enoent flag to RGWSimpleRadosReadCR X-Git-Tag: v11.0.1~24^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c5c95e7f225d59a8bdd8eda3742053b77492c40c;p=ceph.git rgw: add empty_on_enoent flag to RGWSimpleRadosReadCR RGWSimpleRadosReadCR won't currently fail with ENOENT, but instead passes an empty object to handle_data(). add an empty_on_enoent flag to the constructor, defaulting to true, to make this behavior optional for callers that do want to fail on ENOENT Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index 24a284d63d5..81cae4d2813 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -180,22 +180,21 @@ class RGWSimpleRadosReadCR : public RGWSimpleCoroutine { rgw_bucket pool; string oid; - map *pattrs; + map *pattrs{nullptr}; T *result; + /// on ENOENT, call handle_data() with an empty object instead of failing + const bool empty_on_enoent; - RGWAsyncGetSystemObj *req; + RGWAsyncGetSystemObj *req{nullptr}; public: RGWSimpleRadosReadCR(RGWAsyncRadosProcessor *_async_rados, RGWRados *_store, const rgw_bucket& _pool, const string& _oid, - T *_result) : RGWSimpleCoroutine(_store->ctx()), - async_rados(_async_rados), store(_store), - obj_ctx(store), - pool(_pool), oid(_oid), - pattrs(NULL), - result(_result), - req(NULL) { } + T *_result, bool empty_on_enoent = true) + : RGWSimpleCoroutine(_store->ctx()), async_rados(_async_rados), store(_store), + obj_ctx(store), pool(_pool), oid(_oid), result(_result), + empty_on_enoent(empty_on_enoent) {} ~RGWSimpleRadosReadCR() { request_cleanup(); } @@ -235,7 +234,9 @@ int RGWSimpleRadosReadCR::request_complete() { int ret = req->get_ret_status(); retcode = ret; - if (ret != -ENOENT) { + if (ret == -ENOENT && empty_on_enoent) { + *result = T(); + } else { if (ret < 0) { return ret; } @@ -245,8 +246,6 @@ int RGWSimpleRadosReadCR::request_complete() } catch (buffer::error& err) { return -EIO; } - } else { - *result = T(); } return handle_data(*result);