summaryrefslogtreecommitdiff
path: root/libs/androidfw/AssetManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
-rw-r--r--libs/androidfw/AssetManager.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index f50cff4387d2..07044d0e9d61 100644
--- a/libs/androidfw/AssetManager.cpp
+++ b/libs/androidfw/AssetManager.cpp
@@ -35,6 +35,9 @@
#include <utils/threads.h>
#include <utils/Timers.h>
#include <utils/Trace.h>
+#ifndef _WIN32
+#include <sys/file.h>
+#endif
#include <assert.h>
#include <dirent.h>
@@ -767,6 +770,12 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList,
return;
}
+#ifndef _WIN32
+ if (TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_SH)) != 0) {
+ fclose(fin);
+ return;
+ }
+#endif
char buf[1024];
while (fgets(buf, sizeof(buf), fin)) {
// format of each line:
@@ -797,6 +806,10 @@ void AssetManager::addSystemOverlays(const char* pathOverlaysList,
const_cast<AssetManager*>(this)->mZipSet.addOverlay(targetPackagePath, oap);
}
}
+
+#ifndef _WIN32
+ TEMP_FAILURE_RETRY(flock(fileno(fin), LOCK_UN));
+#endif
fclose(fin);
}
@@ -1892,6 +1905,7 @@ ZipFileRO* AssetManager::SharedZip::getZip()
Asset* AssetManager::SharedZip::getResourceTableAsset()
{
+ AutoMutex _l(gLock);
ALOGV("Getting from SharedZip %p resource asset %p\n", this, mResourceTableAsset);
return mResourceTableAsset;
}
@@ -1901,10 +1915,10 @@ Asset* AssetManager::SharedZip::setResourceTableAsset(Asset* asset)
{
AutoMutex _l(gLock);
if (mResourceTableAsset == NULL) {
- mResourceTableAsset = asset;
// This is not thread safe the first time it is called, so
// do it here with the global lock held.
asset->getBuffer(true);
+ mResourceTableAsset = asset;
return asset;
}
}