diff options
author | Martijn Coenen <maco@google.com> | 2017-01-19 14:14:21 +0100 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2017-01-25 12:36:18 +0100 |
commit | 04b91c0fa5d2ccfe92816791064c30a25cbef0be (patch) | |
tree | 11038a8eac8a0e067153a27425ff56b6686afc55 /transport/memory | |
parent | 8ffa58d176f7c19ff4f003d37a64ccda7b245f70 (diff) | |
download | libhidl-04b91c0fa5d2ccfe92816791064c30a25cbef0be.tar.gz |
Fix hidl_handle/hidl_memory ownership semantics.
hidl_handles that are constructed from a native_handle_t
object never own a handle, unless explicitly requested by
a call to setTo().
Copying a hidl_handle does clone the enclosed native_handle_t
and consequently takes ownership of it.
As a consequence, hidl_memory no longer needs to keep
track of handle ownership; the default constructors
don't take ownership of the passed in native_handle_t,
requiring callers to clean the handles up when it is
done with them. This makes sense because in most cases,
hidl_memory is a very transient object just used for
IPC.
Test: hidl_test, libhidl_test
Bug: 33812533
Change-Id: Idf26434c6a1dc541d4b909ac1523dbf92f214e1a
Diffstat (limited to 'transport/memory')
-rw-r--r-- | transport/memory/1.0/default/AshmemAllocator.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/transport/memory/1.0/default/AshmemAllocator.cpp b/transport/memory/1.0/default/AshmemAllocator.cpp index 59ae3e1..667c46e 100644 --- a/transport/memory/1.0/default/AshmemAllocator.cpp +++ b/transport/memory/1.0/default/AshmemAllocator.cpp @@ -37,6 +37,8 @@ Return<void> AshmemAllocator::allocate(uint64_t size, allocate_cb _hidl_cb) { hidl_memory memory("ashmem", handle, size); _hidl_cb(true /* success */, memory); + native_handle_close(handle); + native_handle_delete(handle); return Void(); } |