storaged: protect global proto_loaded am: 32b5003cf6
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/13113781 Change-Id: Ib7144fecb934f8fe87d964c387320003db111b03
This commit is contained in:
commit
4d4322a32e
2 changed files with 7 additions and 0 deletions
|
|
@ -86,6 +86,7 @@ class storaged_t : public android::hardware::health::V2_0::IHealthInfoCallback,
|
||||||
sp<android::hardware::health::V2_0::IHealth> health;
|
sp<android::hardware::health::V2_0::IHealth> health;
|
||||||
unique_ptr<storage_info_t> storage_info;
|
unique_ptr<storage_info_t> storage_info;
|
||||||
static const uint32_t current_version;
|
static const uint32_t current_version;
|
||||||
|
Mutex proto_lock;
|
||||||
unordered_map<userid_t, bool> proto_loaded;
|
unordered_map<userid_t, bool> proto_loaded;
|
||||||
void load_proto(userid_t user_id);
|
void load_proto(userid_t user_id);
|
||||||
char* prepare_proto(userid_t user_id, StoragedProto* proto);
|
char* prepare_proto(userid_t user_id, StoragedProto* proto);
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,8 @@ storaged_t::storaged_t(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void storaged_t::add_user_ce(userid_t user_id) {
|
void storaged_t::add_user_ce(userid_t user_id) {
|
||||||
|
Mutex::Autolock _l(proto_lock);
|
||||||
|
|
||||||
if (!proto_loaded[user_id]) {
|
if (!proto_loaded[user_id]) {
|
||||||
load_proto(user_id);
|
load_proto(user_id);
|
||||||
proto_loaded[user_id] = true;
|
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) {
|
void storaged_t::remove_user_ce(userid_t user_id) {
|
||||||
|
Mutex::Autolock _l(proto_lock);
|
||||||
|
|
||||||
proto_loaded[user_id] = false;
|
proto_loaded[user_id] = false;
|
||||||
mUidm.clear_user_history(user_id);
|
mUidm.clear_user_history(user_id);
|
||||||
RemoveFileIfExists(proto_path(user_id), nullptr);
|
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) {
|
void storaged_t::flush_protos(unordered_map<int, StoragedProto>* protos) {
|
||||||
|
Mutex::Autolock _l(proto_lock);
|
||||||
|
|
||||||
for (auto& it : *protos) {
|
for (auto& it : *protos) {
|
||||||
/*
|
/*
|
||||||
* Don't flush proto if we haven't attempted to load it from file.
|
* Don't flush proto if we haven't attempted to load it from file.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue