VintfObject::Get* respect skipCache for error case.
If skipCache is false and an object cannot be retrieved,
do not attempt to open and parse the file at the second time.
Test: no duplicated message for the same process:
"Cannot open /odm/manifest.xml"
Change-Id: I6f96ef4c4de39a1ebaf07025a7cdc51809fbee40
Fixes: 71504062
diff --git a/VintfObject.cpp b/VintfObject.cpp
index efe6242..bfceae8 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -35,6 +35,7 @@
struct LockedSharedPtr {
std::shared_ptr<T> object;
std::mutex mutex;
+ bool fetchedOnce = false;
};
struct LockedRuntimeInfoCache {
@@ -49,11 +50,12 @@
bool skipCache,
const F &fetchAllInformation) {
std::unique_lock<std::mutex> _lock(ptr->mutex);
- if (skipCache || ptr->object == nullptr) {
+ if (skipCache || !ptr->fetchedOnce) {
ptr->object = std::make_unique<T>();
if (fetchAllInformation(ptr->object.get()) != OK) {
ptr->object = nullptr; // frees the old object
}
+ ptr->fetchedOnce = true;
}
return ptr->object;
}