未验证 提交 a594a91a 编写于 作者: A Adam Barth 提交者: GitHub

[fuchsia] Set up namespace properly (#4920)

When we converted this code to FIDL2, we moved the FlatNamespace into
SetupNamespace, which meant it grabed the service root handle instead of
leaving it in-place for ApplicationContext::CreateFrom to pick it up.
Now, we pass this object by pointer, which is what we did in FIDL1.
上级 c092e147
......@@ -56,7 +56,7 @@ ApplicationControllerImpl::ApplicationControllerImpl(
auto request = service_provider.NewRequest();
service_provider_bridge_.set_backend(std::move(service_provider));
fdio_ns_t* fdio_ns = SetupNamespace(std::move(startup_info.flat_namespace));
fdio_ns_t* fdio_ns = SetupNamespace(&startup_info.flat_namespace);
if (fdio_ns == nullptr) {
FXL_LOG(ERROR) << "Failed to initialize namespace";
return;
......@@ -66,7 +66,8 @@ ApplicationControllerImpl::ApplicationControllerImpl(
runtime_holder_.reset(new RuntimeHolder());
runtime_holder_->SetMainIsolateShutdownCallback([this]() { Kill(); });
runtime_holder_->Init(
fdio_ns, component::ApplicationContext::CreateFrom(std::move(startup_info)),
fdio_ns,
component::ApplicationContext::CreateFrom(std::move(startup_info)),
std::move(request), std::move(bundle));
}
......@@ -75,24 +76,24 @@ ApplicationControllerImpl::~ApplicationControllerImpl() = default;
constexpr char kServiceRootPath[] = "/svc";
fdio_ns_t* ApplicationControllerImpl::SetupNamespace(
component::FlatNamespace flat) {
component::FlatNamespace* flat) {
fdio_ns_t* fdio_namespc;
zx_status_t status = fdio_ns_create(&fdio_namespc);
if (status != ZX_OK) {
FXL_LOG(ERROR) << "Failed to create namespace";
return nullptr;
}
for (size_t i = 0; i < flat.paths->size(); ++i) {
if (flat.paths->at(i) == kServiceRootPath) {
for (size_t i = 0; i < flat->paths->size(); ++i) {
if (flat->paths->at(i) == kServiceRootPath) {
// Ownership of /svc goes to the ApplicationContext created above.
continue;
}
zx::channel dir = std::move(flat.directories->at(i));
zx::channel dir = std::move(flat->directories->at(i));
zx_handle_t dir_handle = dir.release();
const char* path = flat.paths->at(i)->data();
const char* path = flat->paths->at(i)->data();
status = fdio_ns_bind(fdio_namespc, path, dir_handle);
if (status != ZX_OK) {
FXL_LOG(ERROR) << "Failed to bind " << flat.paths->at(i)
FXL_LOG(ERROR) << "Failed to bind " << flat->paths->at(i)
<< " to namespace";
zx_handle_close(dir_handle);
fdio_ns_destroy(fdio_namespc);
......
......@@ -54,7 +54,7 @@ class ApplicationControllerImpl : public component::ApplicationController,
void StartRuntimeIfReady();
void SendReturnCode(int32_t return_code);
fdio_ns_t* SetupNamespace(component::FlatNamespace flat);
fdio_ns_t* SetupNamespace(component::FlatNamespace* flat);
App* app_;
fidl::Binding<component::ApplicationController> binding_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册