Merge "Adding thread safety to proto uploader"
diff --git a/keystore/operation_proto_handler.cpp b/keystore/operation_proto_handler.cpp
index 1833acb..dfc0692 100644
--- a/keystore/operation_proto_handler.cpp
+++ b/keystore/operation_proto_handler.cpp
@@ -106,6 +106,7 @@
}
void OperationProtoHandler::uploadOpAsProto(Operation& op, bool wasOpSuccessful) {
+ std::lock_guard<std::mutex> lock(op_upload_mutex);
OperationConfig operationConfig;
determinePurpose(op.purpose, &operationConfig);
checkKeyCharacteristics(op.characteristics.softwareEnforced, &operationConfig);
diff --git a/keystore/operation_proto_handler.h b/keystore/operation_proto_handler.h
index 838f3ec..64d0a59 100644
--- a/keystore/operation_proto_handler.h
+++ b/keystore/operation_proto_handler.h
@@ -20,6 +20,7 @@
#include "operation_config.pb.h"
#include "operation_struct.h"
#include <chrono>
+#include <mutex>
#include <unordered_map>
#include <vector>
@@ -35,6 +36,7 @@
private:
std::unordered_map<std::string, int> protoMap;
std::chrono::steady_clock::time_point start_time = std::chrono::steady_clock::now();
+ std::mutex op_upload_mutex;
};
} // namespace keystore