From 5e2d47ebbd0abbcd23b9a7486bbedae0bc4ebb73 Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Fri, 13 Dec 2019 14:03:18 +0800 Subject: Fix the issue that makes GsiService::Cancel to block The GsiService::Get shares the same mutex with other methods. This makes the cancel method to block on the mutex. Bug: 145891864 Test: open two terminals and execute commands below 1st terminal gsi_tool install 2nd terminal gsi_tool cancel Change-Id: Ie458318013dfbbe11c831bf2eb0aa1132dceae30 --- gsi_service.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gsi_service.cpp') diff --git a/gsi_service.cpp b/gsi_service.cpp index 5ef4914..511b080 100644 --- a/gsi_service.cpp +++ b/gsi_service.cpp @@ -59,6 +59,8 @@ using android::base::WriteStringToFd; using android::base::WriteStringToFile; using android::dm::DeviceMapper; +static std::mutex sInstanceLock; + android::wp GsiService::sInstance; // Default userdata image size. @@ -81,7 +83,7 @@ GsiService::GsiService(Gsid* parent) : parent_(parent) { } GsiService::~GsiService() { - std::lock_guard guard(parent_->lock()); + std::lock_guard guard(sInstanceLock); if (sInstance == this) { // No more consumers, gracefully shut down gsid. @@ -90,7 +92,7 @@ GsiService::~GsiService() { } android::sp GsiService::Get(Gsid* parent) { - std::lock_guard guard(parent->lock()); + std::lock_guard guard(sInstanceLock); android::sp service = sInstance.promote(); if (!service) { -- cgit v1.2.3