Skip to content

Commit

Permalink
Check external_services_to_proxy for interfaces from external services
Browse files Browse the repository at this point in the history
If a service appears in external_services_to_proxy, it is supposed to be
registered and stored in services_ as well. BindInterface() should not
query ServiceManager but instead should store this request through
ServiceNotFound for later query when that particular external service is
registered through RegisterExternalServices(..). Otherwise the binding
process to this external service (which only has earlier-registered
service_instance) will be silently dropped if the the client doesn't
set any disconnection handler.

Refer to go/ml-framework-standalone-binary-flakiness for more info.

Bug: b/168555534
Test: CQ

Change-Id: I2f791c924e1b23518704ad7237fc1e5624eaefd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537975
Commit-Queue: Zhaoxin Liang <zxliang@google.com>
Reviewed-by: Kenneth MacKay <kmackay@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827706}
  • Loading branch information
zxliang authored and Commit Bot committed Nov 16, 2020
1 parent fbf8996 commit f7a0342
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion chromecast/external_mojo/public/cpp/external_mojo_broker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "chromecast/external_mojo/public/cpp/external_mojo_broker.h"

#include <map>
#include <set>
#include <utility>

#if defined(OS_LINUX) || defined(OS_CHROMEOS)
Expand Down Expand Up @@ -186,6 +187,9 @@ class ExternalMojoBroker::ConnectorImpl : public mojom::ExternalConnector {
return;
}

external_services_to_proxy_.insert(external_services_to_proxy.begin(),
external_services_to_proxy.end());

for (const auto& service_name : external_services_to_proxy) {
LOG(INFO) << "Register proxy for external " << service_name;
mojo::PendingRemote<service_manager::mojom::Service> service_remote;
Expand Down Expand Up @@ -272,7 +276,9 @@ class ExternalMojoBroker::ConnectorImpl : public mojom::ExternalConnector {
return;
}

if (!connector_) {
auto service_proxy_it = external_services_to_proxy_.find(service_name);

if (!connector_ || service_proxy_it != external_services_to_proxy_.end()) {
ServiceNotFound(service_name, interface_name, std::move(interface_pipe));
return;
}
Expand Down Expand Up @@ -349,6 +355,7 @@ class ExternalMojoBroker::ConnectorImpl : public mojom::ExternalConnector {
std::unique_ptr<service_manager::Connector> connector_;

mojo::ReceiverSet<mojom::ExternalConnector> receivers_;
std::set<std::string> external_services_to_proxy_;
std::map<std::string, std::unique_ptr<ExternalServiceProxy>>
registered_external_services_;

Expand Down

0 comments on commit f7a0342

Please sign in to comment.