summaryrefslogtreecommitdiff
path: root/storaged/storaged.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storaged/storaged.cpp')
-rw-r--r--storaged/storaged.cpp12
1 files changed, 10 insertions, 2 deletions
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.