From: Casey Bodley Date: Sat, 24 Nov 2018 00:28:08 +0000 (-0500) Subject: rgw: add rgw_rados_notify() with optional_yield X-Git-Tag: v15.0.0~26^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2fd33fec5477399615113a70c93ce358a2258d4d;p=ceph.git rgw: add rgw_rados_notify() with optional_yield Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 11645dabb397..b39cfd446b1a 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -171,6 +171,29 @@ int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid, return ioctx.operate(oid, op); } +int rgw_rados_notify(librados::IoCtx& ioctx, const std::string& oid, + bufferlist& bl, uint64_t timeout_ms, bufferlist* pbl, + optional_yield y) +{ +#ifdef HAVE_BOOST_CONTEXT + if (y) { + auto& context = y.get_io_context(); + auto& yield = y.get_yield_context(); + boost::system::error_code ec; + auto reply = librados::async_notify(context, ioctx, oid, + bl, timeout_ms, yield[ec]); + if (pbl) { + *pbl = std::move(reply); + } + return -ec.value(); + } + if (is_asio_thread) { + dout(20) << "WARNING: blocking librados call" << dendl; + } +#endif + return ioctx.notify2(oid, bl, timeout_ms, pbl); +} + void parse_mime_map_line(const char *start, const char *end) { char line[end - start + 1]; diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index b77e99c4f679..d7f3d50afd55 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -41,6 +41,9 @@ int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid, optional_yield y); int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid, librados::ObjectWriteOperation *op, optional_yield y); +int rgw_rados_notify(librados::IoCtx& ioctx, const std::string& oid, + bufferlist& bl, uint64_t timeout_ms, bufferlist* pbl, + optional_yield y); int rgw_tools_init(CephContext *cct); void rgw_tools_cleanup();