MCPcopy Create free account
hub / github.com/ceph/ceph / find_matched_hook

Method find_matched_hook

src/common/admin_socket.cc:616–638  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614}
615
616std::pair<int, AdminSocketHook*>
617AdminSocket::find_matched_hook(std::string& prefix,
618 const cmdmap_t& cmdmap)
619{
620 std::unique_lock l(lock);
621 // Drop lock after done with the lookup to avoid cycles in cases where the
622 // hook takes the same lock that was held during calls to
623 // register/unregister, and set in_hook to allow unregister to wait for us
624 // before removing this hook.
625 auto [hooks_begin, hooks_end] = hooks.equal_range(prefix);
626 if (hooks_begin == hooks_end) {
627 return {ENOENT, nullptr};
628 }
629 // make sure one of the registered commands with this prefix validates.
630 stringstream errss;
631 for (auto hook = hooks_begin; hook != hooks_end; ++hook) {
632 if (validate_cmd(hook->second.desc, cmdmap, errss)) {
633 in_hook = true;
634 return {0, hook->second.hook};
635 }
636 }
637 return {EINVAL, nullptr};
638}
639
640void AdminSocket::queue_tell_command(cref_t<MCommand> m)
641{

Callers

nothing calls this directly

Calls 2

validate_cmdFunction · 0.85
equal_rangeMethod · 0.45

Tested by

no test coverage detected