ANDROID: rust_binder: release threads before refs
Commit 5da94eacba ("ANDROID: rust_binder: print and avoid underflow
with invalid refcnt") added a print when decrementing the refcount if
the ref doesn't exist. This revealed that this sometimes happens inside
thread.release() because the refs were cleared before releasing the
threads. In principle this error is harmless, but to avoid printing this
error, release threads before clearing refs.
Bug: 430660253
Change-Id: I9ceb71ca831f5bb58193e12951245bab19ea4fa2
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
@@ -1303,6 +1303,13 @@ impl Process {
|
||||
work.into_arc().cancel();
|
||||
}
|
||||
|
||||
// Take all threads and release them.
|
||||
let threads = take(&mut self.inner.lock().threads);
|
||||
for thread in threads.values() {
|
||||
thread.release();
|
||||
}
|
||||
drop(threads);
|
||||
|
||||
// Free any resources kept alive by allocated buffers.
|
||||
let omapping = self.inner.lock().mapping.take();
|
||||
if let Some(mut mapping) = omapping {
|
||||
@@ -1344,18 +1351,8 @@ impl Process {
|
||||
}
|
||||
drop(freeze_listeners);
|
||||
|
||||
// Do similar dance for the state lock.
|
||||
let mut inner = self.inner.lock();
|
||||
let threads = take(&mut inner.threads);
|
||||
let nodes = take(&mut inner.nodes);
|
||||
drop(inner);
|
||||
|
||||
// Release all threads.
|
||||
for thread in threads.values() {
|
||||
thread.release();
|
||||
}
|
||||
|
||||
// Deliver death notifications.
|
||||
let nodes = take(&mut self.inner.lock().nodes);
|
||||
for node in nodes.values() {
|
||||
loop {
|
||||
let death = {
|
||||
|
||||
Reference in New Issue
Block a user