Skip to content

Commit

Permalink
neorados: Replace unsafe uses of dispatch with post
Browse files Browse the repository at this point in the history
Dispatch may block the calling thread, so don't use it directly in a
called function. (In handlers is okay, though.)

Signed-off-by: Adam C. Emerson <[email protected]>
  • Loading branch information
adamemerson committed Dec 20, 2020
1 parent 5e60fde commit 747f596
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/neorados/RADOS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ void RADOS::Builder::build(boost::asio::io_context& ioctx,
auto r = cct->_conf.parse_config_files(conf_files ? conf_files->data() : nullptr,
&ss, flags);
if (r < 0)
c->dispatch(std::move(c), ceph::to_error_code(r), RADOS{nullptr});
c->post(std::move(c), ceph::to_error_code(r), RADOS{nullptr});
}

cct->_conf.parse_env(cct->get_module_type());
Expand All @@ -727,15 +727,15 @@ void RADOS::Builder::build(boost::asio::io_context& ioctx,
std::stringstream ss;
auto r = cct->_conf.set_val(n, v, &ss);
if (r < 0)
c->dispatch(std::move(c), ceph::to_error_code(-EINVAL), RADOS{nullptr});
c->post(std::move(c), ceph::to_error_code(-EINVAL), RADOS{nullptr});
}

if (!no_mon_conf) {
MonClient mc_bootstrap(cct, ioctx);
// TODO This function should return an error code.
auto err = mc_bootstrap.get_monmap_and_config();
if (err < 0)
c->dispatch(std::move(c), ceph::to_error_code(err), RADOS{nullptr});
c->post(std::move(c), ceph::to_error_code(err), RADOS{nullptr});
}
if (!cct->_log->is_started()) {
cct->_log->start();
Expand All @@ -756,7 +756,7 @@ void RADOS::make_with_cct(CephContext* cct,
RADOS{std::move(r)});
});
} catch (const bs::system_error& err) {
c->dispatch(std::move(c), err.code(), RADOS{nullptr});
c->post(std::move(c), err.code(), RADOS{nullptr});
}
}

Expand Down Expand Up @@ -909,10 +909,10 @@ void RADOS::lookup_pool(std::string_view name,
ca::dispatch(std::move(c), bs::error_code{}, ret);
});
} else if (ret < 0) {
ca::dispatch(std::move(c), osdc_errc::pool_dne,
ca::post(std::move(c), osdc_errc::pool_dne,
std::int64_t(0));
} else {
ca::dispatch(std::move(c), bs::error_code{}, ret);
ca::post(std::move(c), bs::error_code{}, ret);
}
}

Expand Down Expand Up @@ -1545,7 +1545,7 @@ void RADOS::enable_application(std::string_view pool, std::string_view app_name,
// preserved until Luminous is configured as minimum version.
if (!impl->get_required_monitor_features().contains_all(
ceph::features::mon::FEATURE_LUMINOUS)) {
ca::dispatch(std::move(c), ceph::to_error_code(-EOPNOTSUPP));
ca::post(std::move(c), ceph::to_error_code(-EOPNOTSUPP));
} else {
impl->monclient.start_mon_command(
{ fmt::format("{{ \"prefix\": \"osd pool application enable\","
Expand Down

0 comments on commit 747f596

Please sign in to comment.