| 614 | } |
| 615 | |
| 616 | std::pair<int, AdminSocketHook*> |
| 617 | AdminSocket::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 | |
| 640 | void AdminSocket::queue_tell_command(cref_t<MCommand> m) |
| 641 | { |
nothing calls this directly
no test coverage detected