From bf967c9bdb7f0ce0202a0826dc6b3f61b2ba191f Mon Sep 17 00:00:00 2001 From: Valerie Hau Date: Fri, 21 Jun 2019 11:06:48 -0700 Subject: [PATCH] Wait until old ComposerClient is fully destroyed before recreating Possible race condition where EventCallbacks are registered before old implementation deregisters on destruction. Stems from fact that strong pointer destruction does not mean the object has completely run its destructor method Bug: 135210708 Test: build, boot, VtsHalGraphicsComposerV2_1TargetTest Change-Id: I0851f1197d8341854f5bdac5fbb08553fc32b710 --- .../2.1/utils/hal/include/composer-hal/2.1/Composer.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/Composer.h b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/Composer.h index ad985dafa3..90d9b982a7 100644 --- a/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/Composer.h +++ b/graphics/composer/2.1/utils/hal/include/composer-hal/2.1/Composer.h @@ -109,12 +109,10 @@ class ComposerImpl : public Interface { // inverted (create and then destroy). Wait for a brief period to // see if the existing client is destroyed. ALOGD("waiting for previous client to be destroyed"); - mClientDestroyedCondition.wait_for( - lock, 1s, [this]() -> bool { return mClient.promote() == nullptr; }); - if (mClient.promote() != nullptr) { + mClientDestroyedCondition.wait_for(lock, 1s, + [this]() -> bool { return mClient == nullptr; }); + if (mClient != nullptr) { ALOGD("previous client was not destroyed"); - } else { - mClient.clear(); } }