diff options
author | Martin Wallgren <martin.wallgren@sonymobile.com> | 2016-10-12 21:03:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-10-12 21:03:11 +0000 |
commit | dce79f10ba59e5c6f8a5a38ccb5075c5907d6d46 (patch) | |
tree | b0147fdb458c9b3df55a8b4325c4e12aefa24b58 /libs/androidfw/AssetManager.cpp | |
parent | 64d24d6631eb7faea90b1328fe25314637bd391b (diff) | |
parent | 0fbb60811076e6fcfd576287b6e6a16ac1a69c44 (diff) |
RRO: Synchronize access to overlays.list
am: 0fbb608110
Change-Id: I44a716df3954b6d2d58d7c9784f8b55cf041b10b
Diffstat (limited to 'libs/androidfw/AssetManager.cpp')
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 043989874bc8..4c1c1b935980 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> @@ -768,6 +771,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: @@ -798,6 +807,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); } |