diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-15 19:20:13 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2021-01-15 19:20:13 +0000 |
commit | 7161f691da892a539ea5476ec22805b5654ca725 (patch) | |
tree | a9e2267a96eea661579e5f24bb9e8fcdb012d1f3 | |
parent | 591e683c210cdc2866d487137cd2c2278802ff77 (diff) | |
parent | 4d3fe5ab72df92d3d77921fff65a2ce1529c0da6 (diff) | |
download | core-android12-mainline-tzdata-release.tar.gz |
Snap for 7084909 from 4d3fe5ab72df92d3d77921fff65a2ce1529c0da6 to qt-aml-tzdata-releaseq_tzdata_aml_294400310android-mainline-12.0.0_r54android-mainline-12.0.0_r111android-mainline-10.0.0_r13android-mainline-10.0.0_r12android12-mainline-tzdata-release
Change-Id: I0e3e8a2ef1522f26fd589745fd7179821df74b69
-rw-r--r-- | storaged/include/storaged.h | 1 | ||||
-rw-r--r-- | storaged/storaged.cpp | 12 |
2 files changed, 11 insertions, 2 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 689766382..3e0f70d3a 100644 --- a/storaged/storaged.cpp +++ b/storaged/storaged.cpp @@ -164,11 +164,17 @@ storaged_t::storaged_t(void) { } void storaged_t::add_user_ce(userid_t user_id) { - load_proto(user_id); - proto_loaded[user_id] = true; + Mutex::Autolock _l(proto_lock); + + if (!proto_loaded[user_id]) { + load_proto(user_id); + proto_loaded[user_id] = true; + } } 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); @@ -299,6 +305,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. |