return watchers[i].get_obj();
}
-int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp, optional_yield y)
+int RGWSI_Notify::init_watch(const DoutPrefixProvider *dpp,
+ boost::asio::yield_context yield)
{
num_watchers = cct->_conf->rgw_num_control_oids;
const size_t max_aio = cct->_conf.get_val<int64_t>("rgw_max_control_aio");
auto throttle = ceph::async::spawn_throttle{
- y, max_aio, ceph::async::cancel_on_error::all};
+ yield, max_aio, ceph::async::cancel_on_error::all};
watchers.reserve(num_watchers);
for (int i=0; i < num_watchers; i++) {
return 0;
}
-void RGWSI_Notify::finalize_watch()
+void RGWSI_Notify::finalize_watch(boost::asio::yield_context yield)
{
const size_t max_aio = cct->_conf.get_val<int64_t>("rgw_max_control_aio");
auto throttle = ceph::async::spawn_throttle{
- null_yield, max_aio, ceph::async::cancel_on_error::all};
+ yield, max_aio, ceph::async::cancel_on_error::all};
for (int i = 0; i < num_watchers; i++) {
if (!watchers_set.contains(i)) {
continue;
control_pool = zone_svc->get_zone_params().control_pool;
- int ret = init_watch(dpp, y);
+ int ret = 0;
+
+ // if we're not running in a coroutine, spawn one
+ if (!y) {
+ boost::asio::io_context context;
+ boost::asio::spawn(context,
+ [this, dpp] (boost::asio::yield_context yield) {
+ return init_watch(dpp, yield);
+ },
+ [&ret] (std::exception_ptr eptr, int result) {
+ if (eptr) {
+ std::rethrow_exception(eptr);
+ } else {
+ ret = result;
+ }
+ });
+ context.run();
+ } else {
+ ret = init_watch(dpp, y.get_yield_context());
+ }
if (ret < 0) {
ldpp_dout(dpp, -1) << "ERROR: failed to initialize watch: " << cpp_strerror(-ret) << dendl;
return ret;
if (finisher_handle) {
finisher_svc->unregister_caller(*finisher_handle);
}
- finalize_watch();
+
+ // we're not running in a coroutine, so spawn one
+ boost::asio::io_context context;
+ boost::asio::spawn(context,
+ [this] (boost::asio::yield_context yield) {
+ finalize_watch(yield);
+ },
+ [] (std::exception_ptr eptr) {
+ if (eptr) std::rethrow_exception(eptr);
+ });
+ context.run();
delete shutdown_cb;