summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-12-15 21:47:49 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-12-15 21:47:49 +0000
commit8969a598cc42e8408d66483cbb64d94ecec57655 (patch)
tree9100e237ca73ceb90ff869146b5ef4110ccaabac
parent69522b36f776a2a8ad7e2ce69cfb58f60165b3d5 (diff)
parent341cfd6b562aec56ce0786693d44a1dc72cb0431 (diff)
Merge cherrypicks of [13231585, 13231436, 13231587, 13230396, 13230398, 13231349, 13231352, 13231353, 13231355, 13231438, 13231440, 13231357, 13231442, 13231359, 13231031, 13231456, 13230694, 13231724, 13231033, 13230839, 13231035, 13230841, 13230843, 13231362, 13231744, 13231746, 13231459, 13231748, 13231750, 13231752, 13229581, 13229583, 13231590, 13231592, 13231765, 13230401, 13230403, 13231785, 13231787, 13231789, 13231791] into rvc-qpr1-d-release
Change-Id: I3822071d89a894299f84fa702fcac85d82c86bbe
-rw-r--r--storaged/include/storaged.h1
-rw-r--r--storaged/storaged.cpp6
2 files changed, 7 insertions, 0 deletions
diff --git a/storaged/include/storaged.h b/storaged/include/storaged.h
index 6f9204879..79b5d41ac 100644
--- a/storaged/include/storaged.h
+++ b/storaged/include/storaged.h
@@ -86,6 +86,7 @@ class storaged_t : public android::hardware::health::V2_0::IHealthInfoCallback,
sp<android::hardware::health::V2_0::IHealth> health;
unique_ptr<storage_info_t> storage_info;
static const uint32_t current_version;
+ Mutex proto_lock;
unordered_map<userid_t, bool> proto_loaded;
void load_proto(userid_t user_id);
char* prepare_proto(userid_t user_id, StoragedProto* proto);
diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp
index 573b8c563..b7aa89ff7 100644
--- a/storaged/storaged.cpp
+++ b/storaged/storaged.cpp
@@ -162,6 +162,8 @@ storaged_t::storaged_t(void) {
}
void storaged_t::add_user_ce(userid_t user_id) {
+ Mutex::Autolock _l(proto_lock);
+
if (!proto_loaded[user_id]) {
load_proto(user_id);
proto_loaded[user_id] = true;
@@ -169,6 +171,8 @@ void storaged_t::add_user_ce(userid_t user_id) {
}
void storaged_t::remove_user_ce(userid_t user_id) {
+ Mutex::Autolock _l(proto_lock);
+
proto_loaded[user_id] = false;
mUidm.clear_user_history(user_id);
RemoveFileIfExists(proto_path(user_id), nullptr);
@@ -298,6 +302,8 @@ void storaged_t::flush_proto(userid_t user_id, StoragedProto* proto) {
}
void storaged_t::flush_protos(unordered_map<int, StoragedProto>* protos) {
+ Mutex::Autolock _l(proto_lock);
+
for (auto& it : *protos) {
/*
* Don't flush proto if we haven't attempted to load it from file.