Add comment that SharedBuffer is deprecated.
Both aref and SharedBuffer had memory ordering bugs. Aref has no
clients.
SharedBuffer had several bugs, which are fixed here:
mRefs was declared neither volatile, not atomic, allowing the
compiler to, for example, reuse a stale previously loaded value.
It used the default android_atomic release memory ordering, which
is insufficient for reference count decrements.
It used an ordinary memory read in onlyOwner() to check whether
an object is safe to deallocate, without any attempt to ensure
memory ordering.
Comments claimed that SharedBuffer was exactly 16 bytes, but
this was neither checked, nor correct on 64-bit platforms.
This turns mRef into a std::atomic and removes the android_atomic
dependency.
Bug: 28826227
Change-Id: I39fa0b4f70ac0471b14ad274806fc4e0c0802e78
Convert to use std::atomic directly.
Consistently use relaxed ordering for increments, release ordering
for decrements, and an added acquire fence when the count goes to
zero.
Fix what looks like another race in attemptIncStrong:
It seems entirely possible that the final adjustment for
INITIAL_STRONG_VALUE would see e.g. INITIAL_STRONG_VALUE + 1,
since we could be running in the middle of another initial
increment.
Attempt to somewhat document what this actually does, and
what's expected from the client. Hide the documentation in
the .cpp file for now.
Remove a confusing redundant test in decWeak. OBJECT_LIFETIME_STRONG
and OBJECT_LIFETIME_WEAK are the only options, in spite of some
of the original comments.
It's conceivable that either of these issues has resulted in
actual crashes, though I would guess the probability is small.
It's hard enough to reason about this code without the bugs.
Bug: 28705989
Change-Id: I4107a56c3fc0fdb7ee17fc8a8f0dd7fb128af9d8
(cherry picked from commit e263e6c633)
am: 11082d3a6e
* commit '11082d3a6e7b4b0c848bcea70e8abf16885f3e08':
adb: use asocket's close function when closing.
adb: switch the socket list mutex to a recursive_mutex.
adb: clang-format sockets.cpp.
adb: add implementations of mutex, recursive_mutex.
Change-Id: I76ee3a8d2de618c57b3696e78261fdbb917edab8
am: d4af0d64de
* commit 'd4af0d64de042b0425bbae1f91d1720eebcf95a3':
adb: use asocket's close function when closing.
adb: switch the socket list mutex to a recursive_mutex.
adb: clang-format sockets.cpp.
adb: add implementations of mutex, recursive_mutex.
Change-Id: Ibb251966874a73e7ad745531ebad7b56c9c82e0d
am: d4af0d64de
* commit 'd4af0d64de042b0425bbae1f91d1720eebcf95a3':
adb: use asocket's close function when closing.
adb: switch the socket list mutex to a recursive_mutex.
adb: clang-format sockets.cpp.
adb: add implementations of mutex, recursive_mutex.
Change-Id: Ida004443ba8cc7d41a2b81d77c7abb9917e08ff9
* changes:
adb: use asocket's close function when closing.
adb: switch the socket list mutex to a recursive_mutex.
adb: clang-format sockets.cpp.
adb: add implementations of mutex, recursive_mutex.
am: a41a0c2acc
* commit 'a41a0c2acc4cebfd8d47522fe57756d7f90e49e1':
adb: use asocket's close function when closing.
Change-Id: Id18d3b3671d777dd8c8415c8d540aa189157f64a
close_all_sockets was assuming that all registered local sockets used
local_socket_close as their close function. However, this is not true
for JDWP sockets.
Bug: http://b/28347842
Change-Id: I40a1174845cd33f15f30ce70828a7081cd5a087e
(cherry picked from commit 53eb31d87c)
sockets.cpp was branching on whether a socket close function was
local_socket_close in order to avoid a potential deadlock if the socket
list lock was held while closing a peer socket.
Bug: http://b/28347842
Change-Id: I5e56f17fa54275284787f0f1dc150d1960256ab3
(cherry picked from commit 9b587dec6d)
Our version of mingw doesn't support std::mutex or
std::recursive_mutex, so implement our own using the Windows primitives.
Bug: http://b/28347842
Change-Id: I4e1d56a89bc5fcb5f859bf5014343697a4a85b77
(cherry picked from commit 903b749f78)
am: 43c058e51a
* commit '43c058e51a652874cfdf0c687ba1dee18f13f993':
adb: use asocket's close function when closing.
Change-Id: I0681ff8c31c2f221e246a86857fbff779d2b7dcf