summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMartin Wallgren <martin.wallgren@sonymobile.com>2015-08-11 15:10:31 +0200
committerAdam Lesinski <adamlesinski@google.com>2016-10-12 14:56:31 +0000
commit0fbb60811076e6fcfd576287b6e6a16ac1a69c44 (patch)
tree316e242fdf315b77ab518670996598a11a91ca1b /libs
parent52cd2948a622a7793f315b29239c3faee7d84ab3 (diff)
downloadandroid-frameworks-base-0fbb60811076e6fcfd576287b6e6a16ac1a69c44.tar.gz
android-frameworks-base-0fbb60811076e6fcfd576287b6e6a16ac1a69c44.tar.xz
RRO: Synchronize access to overlays.list
idmap --scan is executed as a part of the pre-loading in ZygoteInit. The pre loading is executed in parallel for each supported architecture (32/64 bit). This will cause a race condition in the creation of the overlays.list file and the idmap files for the system overlays. Apply flock on overlays.list to prevent the file from being thrown away and recreated when it is in use by another Zygote. Cherry-picked from AOSP. Bug: 28032298 Test: manual Change-Id: I51d39f121d207b11181340b68b164b60020f0c61
Diffstat (limited to 'libs')
-rw-r--r--libs/androidfw/AssetManager.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp
index 8ea25d6..07044d0 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);
}