Fix crash due to race on close()

It's possible for close to be called during local cleanup concurrently
with the remote call.

A recent change (ag/15993920) added a missing Binder.unlinkToDeath
call to close(). This now causes a crash now if the registration
was removed at just the right time in another thread. This synchronizes
access to close() to avoid this.

Bug: 237406501
Test: atest ScrollCaptureConnectionTest
Change-Id: I0126bfac1efdece2e4eff144a44f29a963553b74
This commit is contained in:
Mark Renouf
2022-06-28 20:27:46 +00:00
parent 0251a89274
commit a433556fc0

View File

@@ -214,7 +214,7 @@ public class ScrollCaptureConnection extends IScrollCaptureConnection.Stub imple
@BinderThread
@Override
public void close() {
public synchronized void close() {
Trace.instantForTrack(TRACE_TAG_GRAPHICS, TRACE_TRACK, "close");
if (mActive) {
Log.w(TAG, "close(): capture session still active! Ending now.");