| 653 | } |
| 654 | |
| 655 | int AdminSocket::register_command(std::string_view cmddesc, |
| 656 | AdminSocketHook *hook, |
| 657 | std::string_view help) |
| 658 | { |
| 659 | int ret; |
| 660 | std::unique_lock l(lock); |
| 661 | string prefix = cmddesc_get_prefix(cmddesc); |
| 662 | auto i = hooks.find(prefix); |
| 663 | if (i != hooks.cend() && |
| 664 | i->second.desc == cmddesc) { |
| 665 | ldout(m_cct, 5) << "register_command " << prefix |
| 666 | << " cmddesc " << cmddesc << " hook " << hook |
| 667 | << " EEXIST" << dendl; |
| 668 | ret = -EEXIST; |
| 669 | } else { |
| 670 | ldout(m_cct, 5) << "register_command " << prefix << " hook " << hook |
| 671 | << dendl; |
| 672 | hooks.emplace_hint(i, |
| 673 | std::piecewise_construct, |
| 674 | std::forward_as_tuple(prefix), |
| 675 | std::forward_as_tuple(hook, cmddesc, help)); |
| 676 | ret = 0; |
| 677 | } |
| 678 | return ret; |
| 679 | } |
| 680 | |
| 681 | void AdminSocket::unregister_commands(const AdminSocketHook *hook) |
| 682 | { |