return ret;
}
-int AdminSocket::unregister_command(std::string_view command)
-{
- int ret;
- std::unique_lock l(lock);
- auto i = hooks.find(command);
- if (i != hooks.cend()) {
- ldout(m_cct, 5) << "unregister_command " << command << dendl;
-
- // If we are currently processing a command, wait for it to
- // complete in case it referenced the hook that we are
- // unregistering.
- in_hook_cond.wait(l, [this]() { return !in_hook; });
-
- hooks.erase(i);
-
-
- ret = 0;
- } else {
- ldout(m_cct, 5) << "unregister_command " << command << " ENOENT" << dendl;
- ret = -ENOENT;
- }
- return ret;
-}
-
void AdminSocket::unregister_commands(const AdminSocketHook *hook)
{
std::unique_lock l(lock);
unregister_commands(version_hook.get());
version_hook.reset();
- unregister_command("help");
+ unregister_commands(help_hook.get());
help_hook.reset();
- unregister_command("get_command_descriptions");
+ unregister_commands(getdescs_hook.get());
getdescs_hook.reset();
remove_cleanup_file(m_path);
AdminSocketHook *hook,
std::string_view help);
- /**
- * unregister an admin socket command.
- *
- * If a command is currently in progress, this will block until it
- * is done. For that reason, you must not hold any locks required
- * by your hook while you call this.
- *
- * @param command command string
- * @return 0 on succest, -ENOENT if command dne.
- */
- int unregister_command(std::string_view command);
-
/*
* unregister all commands belong to hook.
*/
}
~MempoolObs() override {
cct->_conf.remove_observer(this);
- cct->get_admin_socket()->unregister_command("dump_mempools");
+ cct->get_admin_socket()->unregister_commands(this);
}
// md_config_obs_t
}
LibrbdAdminSocketHook::~LibrbdAdminSocketHook() {
+ (void)admin_socket->unregister_commands(this);
for (Commands::const_iterator i = commands.begin(); i != commands.end();
++i) {
- (void)admin_socket->unregister_command(i->first);
delete i->second;
}
}
{
AdminSocket *admin_socket = g_ceph_context->get_admin_socket();
if (admin_socket && alloc) {
- int r = admin_socket->unregister_command(("bluestore allocator dump " + name).c_str());
- ceph_assert(r == 0);
- r = admin_socket->unregister_command(("bluestore allocator score " + name).c_str());
- ceph_assert(r == 0);
- r = admin_socket->unregister_command(("bluestore allocator fragmentation " + name).c_str());
- ceph_assert(r == 0);
+ admin_socket->unregister_commands(this);
}
}
~SocketHook() {
AdminSocket* admin_socket = bluefs->cct->get_admin_socket();
- int r = admin_socket->unregister_command("bluestore bluefs available");
- ceph_assert(r == 0);
+ admin_socket->unregister_commands(this);
}
private:
SocketHook(BlueFS* bluefs) :
// shutdown() with the ::initialized check at start.
if (m_request_state_hook) {
AdminSocket* admin_socket = cct->get_admin_socket();
- admin_socket->unregister_command("objecter_requests");
+ admin_socket->unregister_commands(m_request_state_hook);
delete m_request_state_hook;
m_request_state_hook = NULL;
}
{
AdminSocket *admin_socket = cct->get_admin_socket();
if (!admin_command.empty()) {
- admin_socket->unregister_command(admin_command);
+ admin_socket->unregister_commands(this);
}
}
{
AdminSocket *admin_socket = cct->get_admin_socket();
if (!admin_command.empty()) {
- admin_socket->unregister_command(admin_command);
+ admin_socket->unregister_commands(this);
}
admin_command = command;
int r = admin_socket->register_command(admin_command, this,
}
~ImageDeleterAdminSocketHook() override {
+ (void)admin_socket->unregister_commands(this);
for (Commands::const_iterator i = commands.begin(); i != commands.end();
++i) {
- (void)admin_socket->unregister_command(i->first);
delete i->second;
}
}
}
~ImageReplayerAdminSocketHook() override {
+ admin_socket->unregister_commands(this);
for (auto &it : commands) {
- if (it.second->registered) {
- admin_socket->unregister_command(it.first);
- }
delete it.second;
}
commands.clear();
}
~MirrorAdminSocketHook() override {
+ (void)admin_socket->unregister_commands(this);
for (Commands::const_iterator i = commands.begin(); i != commands.end();
++i) {
- (void)admin_socket->unregister_command(i->first);
delete i->second;
}
}
}
~PoolReplayerAdminSocketHook() override {
+ (void)admin_socket->unregister_commands(this);
for (auto i = commands.begin(); i != commands.end(); ++i) {
- (void)admin_socket->unregister_command(i->first);
delete i->second;
}
}