summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2010-10-04 14:20:14 -0700
committerKenny Root <kroot@google.com>2010-10-04 15:17:19 -0700
commit61ef747e0e1b3980fbb10ce48de575caa69a6a74 (patch)
treef9e8441c3b0216ce0af144f3c9edbd0d7f43ca30 /include
parent1da40fbd474e378235877738ee622bbf8093ce6c (diff)
downloadframeworks_native-61ef747e0e1b3980fbb10ce48de575caa69a6a74.zip
frameworks_native-61ef747e0e1b3980fbb10ce48de575caa69a6a74.tar.gz
frameworks_native-61ef747e0e1b3980fbb10ce48de575caa69a6a74.tar.bz2
Use pread() in ZipFileRO for Linux
AssetManager instances are created by zygote and passed to all its children so that they don't have to individually open frameworks-res.apk. This creates a problem for determining the current file offset when using lseek() on those files, because you can't guarantee the cross-process locking of a mutex. Luckily, Linux implements pread() to get around this suckiness. The problem is that only Linux implements this, so we have to keep the old locking for use on host builds with aapt and friends. aapt doesn't have this same problem of sharing file descriptors across forked processes, so we can keep the local AutoMutex to protect accesses of those files. Change-Id: Ibe9f11499a53fe345f50fbaea438815ec0fd363e
Diffstat (limited to 'include')
-rw-r--r--include/utils/ZipFileRO.h24
1 files changed, 17 insertions, 7 deletions
diff --git a/include/utils/ZipFileRO.h b/include/utils/ZipFileRO.h
index e1ff780..3c1f3ca 100644
--- a/include/utils/ZipFileRO.h
+++ b/include/utils/ZipFileRO.h
@@ -14,13 +14,19 @@
* limitations under the License.
*/
-//
-// Read-only access to Zip archives, with minimal heap allocation.
-//
-// This is similar to the more-complete ZipFile class, but no attempt
-// has been made to make them interchangeable. This class operates under
-// a very different set of assumptions and constraints.
-//
+/*
+ * Read-only access to Zip archives, with minimal heap allocation.
+ *
+ * This is similar to the more-complete ZipFile class, but no attempt
+ * has been made to make them interchangeable. This class operates under
+ * a very different set of assumptions and constraints.
+ *
+ * One such assumption is that if you're getting file descriptors for
+ * use with this class as a child of a fork() operation, you must be on
+ * a pread() to guarantee correct operation. This is because pread() can
+ * atomically read at a file offset without worrying about a lock around an
+ * lseek() + read() pair.
+ */
#ifndef __LIBS_ZIPFILERO_H
#define __LIBS_ZIPFILERO_H
@@ -55,6 +61,10 @@ typedef void* ZipEntryRO;
* the record structure. However, this requires a private mapping of
* every page that the Central Directory touches. Easier to tuck a copy
* of the string length into the hash table entry.
+ *
+ * NOTE: If this is used on file descriptors inherited from a fork() operation,
+ * you must be on a platform that implements pread() to guarantee correctness
+ * on the shared file descriptors.
*/
class ZipFileRO {
public: