diff options
| author | 2015-11-18 21:42:30 +0000 | |
|---|---|---|
| committer | 2015-11-18 21:42:30 +0000 | |
| commit | fb92cfcd3e8977a6cac0147de80bf2a0fb6a2d87 (patch) | |
| tree | ae67c44c4486dc5c17ba94a5e8c8fc1468deeaef /libs/binder/Parcel.cpp | |
| parent | 0dd1a5d2f4e69c5df233fa9468191c03dc9b639f (diff) | |
| parent | 5cd09786eb4ff6e99351e8a317205a5efd12ac74 (diff) | |
Merge "Revert "Add support for unique_fds and vectors of file descriptors""
am: 5cd09786eb
* commit '5cd09786eb4ff6e99351e8a317205a5efd12ac74':
Revert "Add support for unique_fds and vectors of file descriptors"
Diffstat (limited to 'libs/binder/Parcel.cpp')
| -rw-r--r-- | libs/binder/Parcel.cpp | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp index 92b80e9c6a..1b41eae631 100644 --- a/libs/binder/Parcel.cpp +++ b/libs/binder/Parcel.cpp @@ -80,8 +80,6 @@ struct small_flat_data namespace android { -using android::base::unique_fd; - static pthread_mutex_t gParcelGlobalAllocSizeLock = PTHREAD_MUTEX_INITIALIZER; static size_t gParcelGlobalAllocSize = 0; static size_t gParcelGlobalAllocCount = 0; @@ -1075,20 +1073,12 @@ status_t Parcel::writeDupFileDescriptor(int fd) return -errno; } status_t err = writeFileDescriptor(dupFd, true /*takeOwnership*/); - if (err != OK) { + if (err) { close(dupFd); } return err; } -status_t Parcel::writeUniqueFileDescriptor(const unique_fd& fd) { - return writeDupFileDescriptor(fd.get()); -} - -status_t Parcel::writeUniqueFileDescriptorVector(const std::vector<unique_fd>& val) { - return writeTypedVector(val, this, &Parcel::writeUniqueFileDescriptor); -} - status_t Parcel::writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob) { if (len > INT32_MAX) { @@ -1690,36 +1680,16 @@ native_handle* Parcel::readNativeHandle() const int Parcel::readFileDescriptor() const { const flat_binder_object* flat = readObject(true); - - if (flat && flat->type == BINDER_TYPE_FD) { - return flat->handle; + if (flat) { + switch (flat->type) { + case BINDER_TYPE_FD: + //ALOGI("Returning file descriptor %ld from parcel %p", flat->handle, this); + return flat->handle; + } } - return BAD_TYPE; } -status_t Parcel::readUniqueFileDescriptor(unique_fd* val) const -{ - int got = readFileDescriptor(); - - if (got == BAD_TYPE) { - return BAD_TYPE; - } - - val->reset(dup(got)); - - if (val->get() < 0) { - return BAD_VALUE; - } - - return OK; -} - - -status_t Parcel::readUniqueFileDescriptorVector(std::vector<unique_fd>* val) const { - return readTypedVector(val, this, &Parcel::readUniqueFileDescriptor); -} - status_t Parcel::readBlob(size_t len, ReadableBlob* outBlob) const { int32_t blobType; |