TODO(torek): combine (template) with ModuleBuilder::RunCommand
| 183 | |
| 184 | // TODO(torek): combine (template) with ModuleBuilder::RunCommand |
| 185 | CommandResponse GateHookBuilder::RunCommand( |
| 186 | GateHook *hook, const std::string &user_cmd, |
| 187 | const google::protobuf::Any &arg) const { |
| 188 | Module *mod = hook->gate()->module(); |
| 189 | for (auto &cmd : cmds_) { |
| 190 | if (user_cmd == cmd.cmd) { |
| 191 | if (cmd.mt_safe != GateHookCommand::THREAD_SAFE && |
| 192 | mod->HasRunningWorker()) { |
| 193 | return CommandFailure(EBUSY, |
| 194 | "There is a running worker and command " |
| 195 | "'%s' is not MT safe", |
| 196 | cmd.cmd.c_str()); |
| 197 | } |
| 198 | |
| 199 | return cmd.func(hook, arg); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | return CommandFailure(ENOTSUP, "'%s' does not support command '%s'", |
| 204 | class_name_.c_str(), user_cmd.c_str()); |
| 205 | } |
| 206 | |
| 207 | void Gate::ClearHooks() { |
| 208 | for (auto &hook : hooks_) { |
nothing calls this directly
no test coverage detected