PSA: FIDL one way interactions will hide PEER_CLOSED

5 views
Skip to first unread message

Mitchell Kember

unread,
Feb 14, 2023, 4:23:05 PM2/14/23
to fidl-dev, rust-...@fuchsia.dev

TL;DR: To avoid race conditions, we are changing FIDL bindings behavior to hide PEER_CLOSED errors when making one-way calls and sending replies/events. This is done for C++, and will be soon for Rust.



In the past, most FIDL bindings have exposed PEER_CLOSED errors from one-way interactions (clients making one-way calls, servers sending replies, and servers sending events). This was a mistake because it leads to racy code, so we are now fixing it, tracked in fxbug.dev/113160:



Conceptually, one-way interactions are “fire and forget”. There is never any guarantee that the receiver has received the message. Even if the channel write succeeds, the remote party could close their channel immediately after that without reading the message. If you want feedback from the remote party, you need to use a two-way method.


While fixing Rust code, one pattern I noticed was error handling for pipelined one-way calls such as fuchsia.io/Directory.Open. With racy PEER_CLOSED errors, there was often duplicate error handling: on the one-way call (in case the directory is closed) and again on the pipelined channel (in case it gets closed without being bound to a server). With PEER_CLOSED hidden on one-way calls, it’s clear that this logic should be consolidated to the second case.


Let me know if you have any questions.



Mitchell


Wez

unread,
Feb 15, 2023, 8:22:15 AM2/15/23
to Mitchell Kember, fidl-dev, rust-...@fuchsia.dev
HLCPP's synchronous bindings return the status from zx_channel_write(), so aren't they also affected?

--
All posts must follow the Fuchsia Code of Conduct https://fuchsia.dev/fuchsia-src/CODE_OF_CONDUCT or may be removed.
---
You received this message because you are subscribed to the Google Groups "fidl-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fidl-dev+u...@fuchsia.dev.
To view this discussion on the web visit https://groups.google.com/a/fuchsia.dev/d/msgid/fidl-dev/CAF4EkWWTQhDu-xCuppsKwjj40jTSs0GZ3DktY8gnA_spjji3mw%40mail.gmail.com.

Mitchell Kember

unread,
Feb 15, 2023, 10:16:26 PM2/15/23
to Wez, fidl-dev, rust-...@fuchsia.dev
Good point, I missed that. Yes, HLCPP sync bindings still expose PEER_CLOSED errors.

We can fix it there too if necessary, but we might just leave as is since the new C++ bindings should be preferred over HLCPP.

Reply all
Reply to author
Forward
0 new messages