summaryrefslogtreecommitdiffstats
path: root/init/init.cpp
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2018-05-08 13:46:39 -0700
committerSteven Moreland <smoreland@google.com>2018-05-08 14:26:44 -0700
commit6227e345e72ddebb71b1e3655d7f79fb76f32271 (patch)
tree2e94d0c1883a7fc7f1a2ba45457ac939a69b8e6a /init/init.cpp
parent612d7a47bd2aea662b8077bf24761d07e7a1ceff (diff)
downloadsystem_core-6227e345e72ddebb71b1e3655d7f79fb76f32271.tar.gz
system_core-6227e345e72ddebb71b1e3655d7f79fb76f32271.tar.bz2
system_core-6227e345e72ddebb71b1e3655d7f79fb76f32271.zip
init: ServiceList FindInterface
FindService can't be used w/ interfaces due to the fact that multiple interfaces can be added to any given interface. Bug: 79418581 Test: boot device, manually use ctl commands Change-Id: I7c152630462c9b7509473bc190f5b30460fcc2bc
Diffstat (limited to 'init/init.cpp')
-rw-r--r--init/init.cpp45
1 files changed, 17 insertions, 28 deletions
diff --git a/init/init.cpp b/init/init.cpp
index 0d5690b07..d3c9968bf 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -277,40 +277,29 @@ void HandleControlMessage(const std::string& msg, const std::string& name, pid_t
const ControlMessageFunction& function = it->second;
- if (function.target == ControlTarget::SERVICE) {
- Service* svc = ServiceList::GetInstance().FindService(name);
- if (svc == nullptr) {
- LOG(ERROR) << "No such service '" << name << "' for ctl." << msg;
- return;
- }
- if (auto result = function.action(svc); !result) {
- LOG(ERROR) << "Could not ctl." << msg << " for service " << name << ": "
- << result.error();
- }
-
- return;
- }
-
- if (function.target == ControlTarget::INTERFACE) {
- for (const auto& svc : ServiceList::GetInstance()) {
- if (svc->interfaces().count(name) == 0) {
- continue;
- }
-
- if (auto result = function.action(svc.get()); !result) {
- LOG(ERROR) << "Could not handle ctl." << msg << " for service " << svc->name()
- << " with interface " << name << ": " << result.error();
- }
+ Service* svc = nullptr;
+ switch (function.target) {
+ case ControlTarget::SERVICE:
+ svc = ServiceList::GetInstance().FindService(name);
+ break;
+ case ControlTarget::INTERFACE:
+ svc = ServiceList::GetInstance().FindInterface(name);
+ break;
+ default:
+ LOG(ERROR) << "Invalid function target from static map key '" << msg << "': "
+ << static_cast<std::underlying_type<ControlTarget>::type>(function.target);
return;
- }
+ }
- LOG(ERROR) << "Could not find service hosting interface " << name;
+ if (svc == nullptr) {
+ LOG(ERROR) << "Could not find '" << name << "' for ctl." << msg;
return;
}
- LOG(ERROR) << "Invalid function target from static map key '" << msg
- << "': " << static_cast<std::underlying_type<ControlTarget>::type>(function.target);
+ if (auto result = function.action(svc); !result) {
+ LOG(ERROR) << "Could not ctl." << msg << " for '" << name << "': " << result.error();
+ }
}
static Result<Success> wait_for_coldboot_done_action(const BuiltinArguments& args) {