diff options
author | Howard Chen <howardsoc@google.com> | 2019-12-13 14:03:18 +0800 |
---|---|---|
committer | Howard Chen <howardsoc@google.com> | 2019-12-25 03:43:29 +0000 |
commit | 5e2d47ebbd0abbcd23b9a7486bbedae0bc4ebb73 (patch) | |
tree | 6ab2dc1ce8ce0a6d4fbf38a4ef2ebda998aa98df /gsi_service.cpp | |
parent | 3ad9598043162193f78796f985d637500b9eab1c (diff) | |
download | gsid-5e2d47ebbd0abbcd23b9a7486bbedae0bc4ebb73.tar.gz |
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
Diffstat (limited to 'gsi_service.cpp')
-rw-r--r-- | gsi_service.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
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> GsiService::sInstance; // Default userdata image size. @@ -81,7 +83,7 @@ GsiService::GsiService(Gsid* parent) : parent_(parent) { } GsiService::~GsiService() { - std::lock_guard<std::mutex> guard(parent_->lock()); + std::lock_guard<std::mutex> guard(sInstanceLock); if (sInstance == this) { // No more consumers, gracefully shut down gsid. @@ -90,7 +92,7 @@ GsiService::~GsiService() { } android::sp<IGsiService> GsiService::Get(Gsid* parent) { - std::lock_guard<std::mutex> guard(parent->lock()); + std::lock_guard<std::mutex> guard(sInstanceLock); android::sp<GsiService> service = sInstance.promote(); if (!service) { |