Commit e905d43e authored by Wez's avatar Wez Committed by Commit Bot

Revert "[fuchsia][mojo/edk] Clone FD if transfer fails"

This reverts commit c2a865c7.

Reason for revert: This causes some IPC and Mojo tests to start failing (see crbug.com/776242).

Original change's description:
> [fuchsia][mojo/edk] Clone FD if transfer fails
> 
> When trying to send a platform handle represented as a file descriptor
> cross-process on Fuchsia, we attempt to transfer the FD in-place which
> is more efficient than the usual clone + send + close pattern. In some
> cases the transfer operation fails, however, so we have to make a fresh
> clone to transfer.
> 
> Bug: 776163
> Change-Id: I6d25e19ee7fef194261f5d1e624a4d8de291d6b3
> Reviewed-on: https://chromium-review.googlesource.com/727121
> Commit-Queue: Wez <wez@chromium.org>
> Reviewed-by: Wez <wez@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#509951}

TBR=wez@chromium.org,jamesr@chromium.org

Change-Id: Icd42bdf3e3d7438b486fd24d4aee5b7d25be32b9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 776163, 776242
Reviewed-on: https://chromium-review.googlesource.com/727027Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#509992}
parent e773c195
......@@ -43,28 +43,18 @@ bool UnwrapPlatformHandle(ScopedPlatformHandle handle,
// Each FDIO file descriptor is implemented using one or more native resources
// and can be un-wrapped into a set of |handle| and |info| pairs, with |info|
// consisting of an FDIO-defined type & arguments (see zircon/processargs.h).
//
// We try to transfer the FD, but if that fails (for example if the file has
// already been dup()d into another FD) we may need to clone.
zx_handle_t handles[FDIO_MAX_HANDLES] = {};
uint32_t info[FDIO_MAX_HANDLES] = {};
zx_status_t result = fdio_transfer_fd(handle.get().as_fd(), 0, handles, info);
if (result == ZX_OK) {
// On success, the fd in |handle| has been transferred and is no longer
// valid. Release from the ScopedPlatformHandle to avoid close()ing an
// invalid handle.
ignore_result(handle.release());
} else if (result == ZX_ERR_UNAVAILABLE) {
// No luck, try cloning instead.
result = fdio_clone_fd(handle.get().as_fd(), 0, handles, info);
}
if (result != ZX_OK) {
DLOG(ERROR) << "fdio_transfer_fd(" << handle.get().as_fd()
<< "): " << zx_status_get_string(result);
DCHECK_LE(result, FDIO_MAX_HANDLES);
if (result <= 0) {
DLOG(ERROR) << "fdio_transfer_fd: " << zx_status_get_string(result);
return false;
}
// The supplied file-descriptor was released by fdio_transfer_fd().
ignore_result(handle.release());
// We assume here that only the |PA_HND_TYPE| of the |info| really matters,
// and that that is the same for all the underlying handles.
*info_out = {PA_HND_TYPE(info[0]), result};
......
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