MCPcopy Create free account
hub / github.com/NetSys/bess / RunCommand

Method RunCommand

core/gate.cc:185–205  ·  view source on GitHub ↗

TODO(torek): combine (template) with ModuleBuilder::RunCommand

Source from the content-addressed store, hash-verified

183
184// TODO(torek): combine (template) with ModuleBuilder::RunCommand
185CommandResponse 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
207void Gate::ClearHooks() {
208 for (auto &hook : hooks_) {

Callers

nothing calls this directly

Calls 4

CommandFailureFunction · 0.85
gateMethod · 0.80
HasRunningWorkerMethod · 0.80
moduleMethod · 0.45

Tested by

no test coverage detected