summaryrefslogtreecommitdiffstats
path: root/opengl/libs/EGL
diff options
context:
space:
mode:
authorvijay gupta <vijayg@nvidia.com>2012-06-27 16:14:42 -0700
committerKirill Artamonov <kartamonov@nvidia.com>2012-07-23 14:26:57 +0300
commita30cc7db8dba9f028333a8e1865006bf6d4f410d (patch)
tree5a11bc76c1efc35273549219aa7bd765490f631a /opengl/libs/EGL
parentdb1597a98958b78dc0d8eced19ae1406382b70d6 (diff)
downloadframeworks_native-a30cc7db8dba9f028333a8e1865006bf6d4f410d.zip
frameworks_native-a30cc7db8dba9f028333a8e1865006bf6d4f410d.tar.gz
frameworks_native-a30cc7db8dba9f028333a8e1865006bf6d4f410d.tar.bz2
EGL: do not use sparse files for shader
- Process is killed by system with SIGBUS signal if it writes data to mapped sparse file on full filesystem. - Allocate space using write() function instead of ftruncate() to avoid creation of sparse files on full filesystem. Catch write() errors to handle out-of-space case during allocation. Bug: http://code.google.com/p/android/issues/detail?id=35376 Change-Id: Ifc366454f34e71a43a0973eda4f591a920ea3a14 Signed-off-by: Kirill Artamonov <kartamonov@nvidia.com>
Diffstat (limited to 'opengl/libs/EGL')
-rw-r--r--opengl/libs/EGL/egl_cache.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/opengl/libs/EGL/egl_cache.cpp b/opengl/libs/EGL/egl_cache.cpp
index c79fb5f..ed2bef3 100644
--- a/opengl/libs/EGL/egl_cache.cpp
+++ b/opengl/libs/EGL/egl_cache.cpp
@@ -241,19 +241,11 @@ void egl_cache_t::saveBlobCacheLocked() {
}
size_t fileSize = headerSize + cacheSize;
- if (ftruncate(fd, fileSize) == -1) {
- ALOGE("error setting cache file size: %s (%d)", strerror(errno),
- errno);
- close(fd);
- unlink(fname);
- return;
- }
- uint8_t* buf = reinterpret_cast<uint8_t*>(mmap(NULL, fileSize,
- PROT_WRITE, MAP_SHARED, fd, 0));
- if (buf == MAP_FAILED) {
- ALOGE("error mmaping cache file: %s (%d)", strerror(errno),
- errno);
+ uint8_t* buf = new uint8_t [fileSize];
+ if (!buf) {
+ ALOGE("error allocating buffer for cache contents: %s (%d)",
+ strerror(errno), errno);
close(fd);
unlink(fname);
return;
@@ -264,7 +256,7 @@ void egl_cache_t::saveBlobCacheLocked() {
if (err != OK) {
ALOGE("error writing cache contents: %s (%d)", strerror(-err),
-err);
- munmap(buf, fileSize);
+ delete [] buf;
close(fd);
unlink(fname);
return;
@@ -275,7 +267,16 @@ void egl_cache_t::saveBlobCacheLocked() {
uint32_t* crc = reinterpret_cast<uint32_t*>(buf + 4);
*crc = crc32c(buf + headerSize, cacheSize);
- munmap(buf, fileSize);
+ if (write(fd, buf, fileSize) == -1) {
+ ALOGE("error writing cache file: %s (%d)", strerror(errno),
+ errno);
+ delete [] buf;
+ close(fd);
+ unlink(fname);
+ return;
+ }
+
+ delete [] buf;
fchmod(fd, S_IRUSR);
close(fd);
}