Commit 676b5fae authored by Wez's avatar Wez Committed by Commit Bot

[mojo] Release() sent handles regardless of zx_channel_write() result.

Fuchsia recently changed the zx_channel_write() API to always consume
the supplied handles, by default, regardless of whether the call
succeeds in transferring them to the peer process.

Update the mojo::edk::Channel::Write() implementation to account for the
new semantics.

Bug: 854458, 754084, 740791
Change-Id: I27f78a09ff8bf2aaf94ac571678d4c2259b48b10
Reviewed-on: https://chromium-review.googlesource.com/1108970Reviewed-by: default avatarWez <wez@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569053}
parent 7a6cb12f
......@@ -397,6 +397,11 @@ class ChannelFuchsia : public Channel,
zx_status_t result =
zx_channel_write(handle_.get().as_handle(), 0, message_view.data(),
write_bytes, handles, handles_count);
// zx_channel_write() consumes |handles| whether or not it succeeds, so
// release() our copies now, to avoid them being double-closed.
for (auto& outgoing_handle : outgoing_handles)
ignore_result(outgoing_handle.release());
if (result != ZX_OK) {
// TODO(fuchsia): Handle ZX_ERR_SHOULD_WAIT flow-control errors, once
// the platform starts generating them. See crbug.com/754084.
......@@ -406,10 +411,6 @@ class ChannelFuchsia : public Channel,
return false;
}
// |handles| have been transferred to the peer process, so release()
// them, to avoid them being double-closed.
for (auto& outgoing_handle : outgoing_handles)
ignore_result(outgoing_handle.release());
} while (write_bytes < message_view.data_num_bytes());
return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment