summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceComposerClient.cpp
diff options
context:
space:
mode:
author Robert Carr <racarr@google.com> 2022-04-04 12:21:37 -0700
committer Robert Carr <racarr@google.com> 2022-04-04 12:23:32 -0700
commit2df7c451a58238bad1d0221af94a2fcb29dd4970 (patch)
treec97b96417733798901cab1abd293957d249f4b99 /libs/gui/SurfaceComposerClient.cpp
parent6451714a234f10fe5c206319ad3cd62d00389a20 (diff)
TransactionCompletedListener: Mutex for getInstance
We have always needed this technically, since otherwise calling getInstance from multiple threads could fail. It seems before we were lucky enough to not actually do that, until the situation in the attached bug arose. Bug: 226882766 Test: Existing tests pass Change-Id: I648f6fa48296599a0c0e0d00a07fb71d9330880d
Diffstat (limited to 'libs/gui/SurfaceComposerClient.cpp')
-rw-r--r--libs/gui/SurfaceComposerClient.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp
index 6c197c457c..88872f8610 100644
--- a/libs/gui/SurfaceComposerClient.cpp
+++ b/libs/gui/SurfaceComposerClient.cpp
@@ -206,12 +206,14 @@ int64_t TransactionCompletedListener::getNextIdLocked() {
}
sp<TransactionCompletedListener> TransactionCompletedListener::sInstance = nullptr;
+static std::mutex sListenerInstanceMutex;
void TransactionCompletedListener::setInstance(const sp<TransactionCompletedListener>& listener) {
sInstance = listener;
}
sp<TransactionCompletedListener> TransactionCompletedListener::getInstance() {
+ std::lock_guard<std::mutex> lock(sListenerInstanceMutex);
if (sInstance == nullptr) {
sInstance = new TransactionCompletedListener;
}