| 90 | } |
| 91 | |
| 92 | CommandResponse ModuleBuilder::RunCommand( |
| 93 | Module *m, const std::string &user_cmd, |
| 94 | const google::protobuf::Any &arg) const { |
| 95 | for (auto &cmd : cmds_) { |
| 96 | if (user_cmd == cmd.cmd) { |
| 97 | if (cmd.mt_safe != Command::THREAD_SAFE && m->HasRunningWorker()) { |
| 98 | return CommandFailure(EBUSY, |
| 99 | "There is a running worker and command " |
| 100 | "'%s' is not MT safe", |
| 101 | cmd.cmd.c_str()); |
| 102 | } |
| 103 | |
| 104 | return cmd.func(m, arg); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | return CommandFailure(ENOTSUP, "'%s' does not support command '%s'", |
| 109 | class_name_.c_str(), user_cmd.c_str()); |
| 110 | } |
| 111 | |
| 112 | CommandResponse ModuleBuilder::RunInit(Module *m, |
| 113 | const google::protobuf::Any &arg) const { |
nothing calls this directly
no test coverage detected