Skip to content

Commit 70c3bd1

Browse files
authored
Revert "[fuchsia] Updates the FIDL bindings in Fuchsia-specific code (#302)" (#303)
This reverts commit b98efcf. The reverted change introduced a 64KB stack allocation which overflowed stacks of some downstream programs.
1 parent b98efcf commit 70c3bd1

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/time_zone_lookup.cc

+17-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#endif
2525

2626
#if defined(__Fuchsia__)
27-
#include <fidl/fuchsia.intl/cpp/fidl.h>
27+
#include <fuchsia/intl/cpp/fidl.h>
2828
#include <lib/async-loop/cpp/loop.h>
2929
#include <lib/fdio/directory.h>
3030
#include <zircon/types.h>
@@ -218,31 +218,32 @@ time_zone local_time_zone() {
218218
// Note: We can't use the synchronous FIDL API here because it doesn't
219219
// allow timeouts; if the FIDL call failed, local_time_zone() would never
220220
// return.
221+
221222
const zx::duration kTimeout = zx::msec(500);
222223

223224
// Don't attach to the thread because otherwise the thread's dispatcher
224225
// would be set to null when the loop is destroyed, causing any other FIDL
225226
// code running on the same thread to crash.
226227
async::Loop loop(&kAsyncLoopConfigNeverAttachToThread);
227-
auto endpoints =
228-
fidl::Endpoints<fuchsia_intl::PropertyProvider>::Create();
228+
229+
fuchsia::intl::PropertyProviderHandle handle;
229230
zx_status_t status = fdio_service_connect_by_name(
230-
fidl::DiscoverableProtocolName<fuchsia_intl::PropertyProvider>,
231-
endpoints.server.TakeChannel().release());
231+
fuchsia::intl::PropertyProvider::Name_,
232+
handle.NewRequest().TakeChannel().release());
232233
if (status != ZX_OK) {
233234
return;
234235
}
235-
fidl::Client intl_provider(
236-
std::move(endpoints.client), loop.dispatcher());
237-
238-
// Attempt to initialize the time zone only once, and fail quietly.
239-
// The end result of an error is an empty time zone string.
240-
intl_provider->GetProfile().Then(
241-
[&loop, &primary_tz](
242-
fidl::Result<fuchsia_intl::PropertyProvider::GetProfile>& result) {
243-
if (result.is_ok()) {
244-
const auto& response = result.value();
245-
primary_tz = response.profile().time_zones().value()[0].id();
236+
237+
fuchsia::intl::PropertyProviderPtr intl_provider;
238+
status = intl_provider.Bind(std::move(handle), loop.dispatcher());
239+
if (status != ZX_OK) {
240+
return;
241+
}
242+
243+
intl_provider->GetProfile(
244+
[&loop, &primary_tz](fuchsia::intl::Profile profile) {
245+
if (!profile.time_zones().empty()) {
246+
primary_tz = profile.time_zones()[0].id;
246247
}
247248
loop.Quit();
248249
});

0 commit comments

Comments
 (0)