OSDN Git Service

Use pread() in ZipFileRO for Linux
authorKenny Root <kroot@google.com>
Mon, 4 Oct 2010 21:20:14 +0000 (14:20 -0700)
committerKenny Root <kroot@google.com>
Mon, 4 Oct 2010 22:17:19 +0000 (15:17 -0700)
commit259ec46e8e80a9f1d0b5c7a3865a498110a7f11b
treec2987b5a006425d41438227011f5b9b5a6febb15
parent106950f20bd352ed72ddf4490b2e19d305e36a74
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
include/utils/ZipFileRO.h
libs/utils/ZipFileRO.cpp